This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@api_view(["GET"]) | |
def user_info(request): | |
return Response({ | |
'user': request.user.username, | |
'expires_in': expires_in(request.auth) | |
}, status=HTTP_200_OK) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [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(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tflearn | |
from tflearn.layers.conv import conv_2d, max_pool_2d | |
from tflearn.layers.core import input_data, dropout, fully_connected | |
from tflearn.layers.estimator import regression | |
convnet = input_data(shape=[None, IMG_SIZE, IMG_SIZE, 1], name='input') | |
#layer | |
convnet = conv_2d(convnet, 32, 2, activation='relu') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Here we set model configuration It all defined at the beginig | |
model.fit( | |
{'input': X}, | |
{'targets': Y}, | |
n_epoch=EPOCHE, | |
validation_set=({'input': test_x}, {'targets': test_y}), | |
snapshot_step=500, show_metric=True, run_id=MODEL_NAME | |
) | |
model.save(MODEL_NAME) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
import os | |
import tflearn | |
from tflearn.layers.conv import conv_2d, max_pool_2d | |
from tflearn.layers.core import input_data, dropout, fully_connected | |
from tflearn.layers.estimator import regression |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.response import Response | |
from rest_framework.decorators import api_view, permission_classes | |
from rest_framework.permissions import AllowAny | |
from rest_framework.status import ( | |
HTTP_200_OK, | |
HTTP_400_BAD_REQUEST, | |
) | |
from .classification_research.CNN import CNN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.urls import path | |
from . import views | |
urlpatterns = [ | |
path('classify/', views.classify), | |
] |