Skip to content

Instantly share code, notes, and snippets.

View yerkbn's full-sized avatar
🎯
Focusing

yerkbn

🎯
Focusing
  • «JIGI» LLP
  • Almaty
View GitHub Profile
# [cat, dog]
def label_image(img):
label = img.split('.')[-3]
if label == 'cat':
return [1,0]
else:
return [0,1]
# Here we generate train data with fixed size and we save it
def create_train_data():
import cv2
import numpy as np
import os
from random import shuffle
from tqdm import tqdm
TRAIN_DIR = '/home/yerkebulan/app/dev/projects/classification_research/dogs-vs-cats/train'
TEST_DIR = '/home/yerkebulan/app/dev/projects/classification_research/dogs-vs-cats/test1'
IMG_SIZE = 50
LR = 1e-3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yerkbn
yerkbn / urls.py
Last active October 7, 2020 08:20
from django.contrib import admin
from django.urls import path
from users.views import signin, user_info
urlpatterns = [
path('admin/', admin.site.urls),
path('api/v1/signin', signin),
path('api/v1/user_info', user_info),
@api_view(["GET"])
def user_info(request):
return Response({
'user': request.user.username,
'expires_in': expires_in(request.auth)
}, status=HTTP_200_OK)
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'users.authentication.ExpiringTokenAuthentication', # custom authentication class
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
)
}
from rest_framework.authentication import TokenAuthentication
from rest_framework.authtoken.models import Token
from rest_framework.exceptions import AuthenticationFailed
from datetime import timedelta
from django.utils import timezone
from django.conf import settings
from rest_framework.authtoken.models import Token
from datetime import timedelta
from django.utils import timezone
from django.conf import settings
#this return left time
def expires_in(token):
@yerkbn
yerkbn / urls.py
Last active October 25, 2018 16:36
from django.contrib import admin
from django.urls import path
from users.views import signin
urlpatterns = [
path('admin/', admin.site.urls),
path('api/v1/signin', signin)
]
from rest_framework import serializers
class UserSigninSerializer(serializers.Serializer):
username = serializers.CharField(required = True)
password = serializers.CharField(required = True)