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
train_images = os.listdir('data/train') | |
train_images[:10] | |
>>> | |
['cat.4213.jpg', | |
'cat.7203.jpg', | |
'dog.8250.jpg', | |
'dog.7907.jpg', | |
'dog.2318.jpg', | |
'cat.6480.jpg', |
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 os | |
import sys | |
import cv2 | |
import random | |
import numpy as np | |
from tqdm import tqdm | |
import pickle |
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
model = Sequential() | |
model.add(Conv2D(64, (3, 3), input_shape=(200, 200, 1))) | |
model.add(Activation('relu')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) | |
model.add(Conv2D(32, (3, 3))) | |
model.add(Activation('relu')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) | |
model.add(Conv2D(16, (3, 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
from django.contrib import admin | |
from django.urls import path | |
from django.views.generic import TemplateView | |
from django.conf import settings | |
from django.conf.urls.static import static | |
import path | |
from pixelart import views |
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 asyncio | |
import websockets | |
import json | |
import string | |
import random | |
import pickle | |
def random_filename(path=None, length=None): | |
text = string.ascii_uppercase + string.ascii_lowercase + string.digits |
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
def login_page(request, template_name="login.html"): | |
context = {'title': 'Login Page'} | |
file_name, answer, _, result_id = generate_captcha() | |
context['captcha_url'] = '/' + file_name | |
context['ref_id'] = result_id | |
return render_to_response(template_name, context) | |
def login_ajax(request): | |
response = {'status': None} | |
if request.method == 'POST': |
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.shortcuts import render, render_to_response | |
import random | |
import string | |
from PIL import Image, ImageFont, ImageDraw | |
from captcha.models import Captcha | |
import json | |
from django.http import HttpResponse, HttpResponseRedirect | |
from django.contrib.auth.models import User | |
from django.contrib.auth import login as django_login | |
def random_filename(path=None, length=None): |
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
/*CSRF Code */ | |
function csrfSafeMethod(method) { | |
// these HTTP methods do not require CSRF protection | |
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); | |
} | |
function sameOrigin(url) { | |
// test that a given url is a same-origin URL | |
// url could be relative or scheme relative or absolute | |
var host = document.location.host; // host + port | |
var protocol = document.location.protocol; |
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 numpy as np | |
import matplotlib.pyplot as plt | |
import datetime | |
import time | |
import tweepy | |
#get this from apps.twitter.com | |
consumer_key = 'xxxx' | |
consumer_secret = 'xxxx' |
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 PIL import Image | |
def get_pixels(image): | |
im = Image.open(image) | |
pixels = [] | |
pix = im.load() | |
width,height = im.size | |
img_width, img_height = 0,0 |