Skip to content

Instantly share code, notes, and snippets.

View yerkbn's full-sized avatar
🎯
Focusing

yerkbn

🎯
Focusing
  • «JIGI» LLP
  • Almaty
View GitHub Profile
@api_view(["GET"])
def user_info(request):
return Response({
'user': request.user.username,
'expires_in': expires_in(request.auth)
}, status=HTTP_200_OK)
@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),
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# [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 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')
# 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)
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
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
from django.urls import path
from . import views
urlpatterns = [
path('classify/', views.classify),
]