Spaces:
Sleeping
Sleeping
Commit
·
5b2de46
0
Parent(s):
first
Browse files- .gitattributes +35 -0
- .github/workflows/main.yml +20 -0
- .gitignore +4 -0
- Colgen1.ipynb +0 -0
- DjangoWeb/.gitignore +138 -0
- DjangoWeb/API/__init__.py +0 -0
- DjangoWeb/API/admin.py +3 -0
- DjangoWeb/API/apps.py +6 -0
- DjangoWeb/API/migrations/__init__.py +0 -0
- DjangoWeb/API/models.py +3 -0
- DjangoWeb/API/tests.py +3 -0
- DjangoWeb/API/urls.py +6 -0
- DjangoWeb/API/views.py +26 -0
- DjangoWeb/DjangoWeb/__init__.py +0 -0
- DjangoWeb/DjangoWeb/asgi.py +16 -0
- DjangoWeb/DjangoWeb/settings.py +125 -0
- DjangoWeb/DjangoWeb/urls.py +25 -0
- DjangoWeb/DjangoWeb/wsgi.py +16 -0
- DjangoWeb/ModelLoader/__init__.py +1 -0
- DjangoWeb/ModelLoader/basemodel.py +17 -0
- DjangoWeb/ModelLoader/colgen1.py +55 -0
- DjangoWeb/main/__init__.py +0 -0
- DjangoWeb/main/admin.py +3 -0
- DjangoWeb/main/apps.py +6 -0
- DjangoWeb/main/migrations/__init__.py +0 -0
- DjangoWeb/main/models.py +3 -0
- DjangoWeb/main/static/main/index.css +122 -0
- DjangoWeb/main/static/main/index.js +65 -0
- DjangoWeb/main/templates/main/index.html +26 -0
- DjangoWeb/main/tests.py +3 -0
- DjangoWeb/main/urls.py +7 -0
- DjangoWeb/main/views.py +6 -0
- DjangoWeb/manage.py +22 -0
- DjangoWeb/requirements.txt +3 -0
- Dockerfile +44 -0
- README.md +37 -0
- test.py +9 -0
- wordtorgb(word2vec).ipynb +0 -0
.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.github/workflows/main.yml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync to Hugging Face hub
|
| 2 |
+
on:
|
| 3 |
+
push:
|
| 4 |
+
branches: [main]
|
| 5 |
+
|
| 6 |
+
# to run this workflow manually from the Actions tab
|
| 7 |
+
workflow_dispatch:
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
sync-to-hub:
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
steps:
|
| 13 |
+
- uses: actions/checkout@v3
|
| 14 |
+
with:
|
| 15 |
+
fetch-depth: 0
|
| 16 |
+
lfs: true
|
| 17 |
+
- name: Push to hub
|
| 18 |
+
env:
|
| 19 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 20 |
+
run: git push https://anuj-panthri:$HF_TOKEN@huggingface.co/spaces/anuj-panthri/imagine-color main --force
|
.gitignore
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.ipynb_checkpoints
|
| 2 |
+
__pycache__
|
| 3 |
+
models
|
| 4 |
+
datasets
|
Colgen1.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
DjangoWeb/.gitignore
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Django #
|
| 2 |
+
*.log
|
| 3 |
+
*.pot
|
| 4 |
+
*.pyc
|
| 5 |
+
__pycache__
|
| 6 |
+
db.sqlite3
|
| 7 |
+
media
|
| 8 |
+
|
| 9 |
+
# Backup files #
|
| 10 |
+
*.bak
|
| 11 |
+
|
| 12 |
+
# If you are using PyCharm #
|
| 13 |
+
# User-specific stuff
|
| 14 |
+
.idea/**/workspace.xml
|
| 15 |
+
.idea/**/tasks.xml
|
| 16 |
+
.idea/**/usage.statistics.xml
|
| 17 |
+
.idea/**/dictionaries
|
| 18 |
+
.idea/**/shelf
|
| 19 |
+
|
| 20 |
+
# AWS User-specific
|
| 21 |
+
.idea/**/aws.xml
|
| 22 |
+
|
| 23 |
+
# Generated files
|
| 24 |
+
.idea/**/contentModel.xml
|
| 25 |
+
|
| 26 |
+
# Sensitive or high-churn files
|
| 27 |
+
.idea/**/dataSources/
|
| 28 |
+
.idea/**/dataSources.ids
|
| 29 |
+
.idea/**/dataSources.local.xml
|
| 30 |
+
.idea/**/sqlDataSources.xml
|
| 31 |
+
.idea/**/dynamic.xml
|
| 32 |
+
.idea/**/uiDesigner.xml
|
| 33 |
+
.idea/**/dbnavigator.xml
|
| 34 |
+
|
| 35 |
+
# Gradle
|
| 36 |
+
.idea/**/gradle.xml
|
| 37 |
+
.idea/**/libraries
|
| 38 |
+
|
| 39 |
+
# File-based project format
|
| 40 |
+
*.iws
|
| 41 |
+
|
| 42 |
+
# IntelliJ
|
| 43 |
+
out/
|
| 44 |
+
|
| 45 |
+
# JIRA plugin
|
| 46 |
+
atlassian-ide-plugin.xml
|
| 47 |
+
|
| 48 |
+
# Python #
|
| 49 |
+
*.py[cod]
|
| 50 |
+
*$py.class
|
| 51 |
+
|
| 52 |
+
# Distribution / packaging
|
| 53 |
+
.Python build/
|
| 54 |
+
develop-eggs/
|
| 55 |
+
dist/
|
| 56 |
+
downloads/
|
| 57 |
+
eggs/
|
| 58 |
+
.eggs/
|
| 59 |
+
lib/
|
| 60 |
+
lib64/
|
| 61 |
+
parts/
|
| 62 |
+
sdist/
|
| 63 |
+
var/
|
| 64 |
+
wheels/
|
| 65 |
+
*.whl
|
| 66 |
+
*.egg-info/
|
| 67 |
+
.installed.cfg
|
| 68 |
+
*.egg
|
| 69 |
+
*.manifest
|
| 70 |
+
*.spec
|
| 71 |
+
|
| 72 |
+
# Installer logs
|
| 73 |
+
pip-log.txt
|
| 74 |
+
pip-delete-this-directory.txt
|
| 75 |
+
|
| 76 |
+
# Unit test / coverage reports
|
| 77 |
+
htmlcov/
|
| 78 |
+
.tox/
|
| 79 |
+
.coverage
|
| 80 |
+
.coverage.*
|
| 81 |
+
.cache
|
| 82 |
+
.pytest_cache/
|
| 83 |
+
nosetests.xml
|
| 84 |
+
coverage.xml
|
| 85 |
+
*.cover
|
| 86 |
+
.hypothesis/
|
| 87 |
+
|
| 88 |
+
# Jupyter Notebook
|
| 89 |
+
.ipynb_checkpoints
|
| 90 |
+
|
| 91 |
+
# pyenv
|
| 92 |
+
.python-version
|
| 93 |
+
|
| 94 |
+
# celery
|
| 95 |
+
celerybeat-schedule.*
|
| 96 |
+
|
| 97 |
+
# SageMath parsed files
|
| 98 |
+
*.sage.py
|
| 99 |
+
|
| 100 |
+
# Environments
|
| 101 |
+
.env
|
| 102 |
+
.venv
|
| 103 |
+
env/
|
| 104 |
+
venv/
|
| 105 |
+
ENV/
|
| 106 |
+
env.bak/
|
| 107 |
+
venv.bak/
|
| 108 |
+
|
| 109 |
+
# mkdocs documentation
|
| 110 |
+
/site
|
| 111 |
+
|
| 112 |
+
# mypy
|
| 113 |
+
.mypy_cache/
|
| 114 |
+
|
| 115 |
+
# Sublime Text #
|
| 116 |
+
*.tmlanguage.cache
|
| 117 |
+
*.tmPreferences.cache
|
| 118 |
+
*.stTheme.cache
|
| 119 |
+
*.sublime-workspace
|
| 120 |
+
*.sublime-project
|
| 121 |
+
|
| 122 |
+
# sftp configuration file
|
| 123 |
+
sftp-config.json
|
| 124 |
+
|
| 125 |
+
# Package control specific files Package
|
| 126 |
+
Control.last-run
|
| 127 |
+
Control.ca-list
|
| 128 |
+
Control.ca-bundle
|
| 129 |
+
Control.system-ca-bundle
|
| 130 |
+
GitHub.sublime-settings
|
| 131 |
+
|
| 132 |
+
# Visual Studio Code #
|
| 133 |
+
.vscode/*
|
| 134 |
+
!.vscode/settings.json
|
| 135 |
+
!.vscode/tasks.json
|
| 136 |
+
!.vscode/launch.json
|
| 137 |
+
!.vscode/extensions.json
|
| 138 |
+
.history
|
DjangoWeb/API/__init__.py
ADDED
|
File without changes
|
DjangoWeb/API/admin.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.contrib import admin
|
| 2 |
+
|
| 3 |
+
# Register your models here.
|
DjangoWeb/API/apps.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.apps import AppConfig
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class ApiConfig(AppConfig):
|
| 5 |
+
default_auto_field = 'django.db.models.BigAutoField'
|
| 6 |
+
name = 'API'
|
DjangoWeb/API/migrations/__init__.py
ADDED
|
File without changes
|
DjangoWeb/API/models.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.db import models
|
| 2 |
+
|
| 3 |
+
# Create your models here.
|
DjangoWeb/API/tests.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.test import TestCase
|
| 2 |
+
|
| 3 |
+
# Create your tests here.
|
DjangoWeb/API/urls.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.urls import path
|
| 2 |
+
from . import views
|
| 3 |
+
|
| 4 |
+
urlpatterns = [
|
| 5 |
+
path('generate',views.generate)
|
| 6 |
+
]
|
DjangoWeb/API/views.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.shortcuts import render
|
| 2 |
+
from django.http import HttpResponse
|
| 3 |
+
from django.views.decorators.csrf import csrf_exempt
|
| 4 |
+
import json
|
| 5 |
+
from ModelLoader import Colgen1
|
| 6 |
+
|
| 7 |
+
model_dir="models/colgen1/"
|
| 8 |
+
model=Colgen1(model_dir)
|
| 9 |
+
|
| 10 |
+
# Create your views here.
|
| 11 |
+
@csrf_exempt
|
| 12 |
+
def generate(request):
|
| 13 |
+
if request.method=='GET':
|
| 14 |
+
return HttpResponse("GET method not allowed")
|
| 15 |
+
elif request.method=='POST':
|
| 16 |
+
received_data = json.loads(request.body.decode("utf-8"))
|
| 17 |
+
print(received_data)
|
| 18 |
+
|
| 19 |
+
out=model.colorToHex(model.predict(received_data['color_names']))
|
| 20 |
+
print(out)
|
| 21 |
+
|
| 22 |
+
data={
|
| 23 |
+
"color_names":received_data["color_names"],
|
| 24 |
+
"colors":out
|
| 25 |
+
}
|
| 26 |
+
return HttpResponse(json.dumps(data))
|
DjangoWeb/DjangoWeb/__init__.py
ADDED
|
File without changes
|
DjangoWeb/DjangoWeb/asgi.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
ASGI config for DjangoWeb project.
|
| 3 |
+
|
| 4 |
+
It exposes the ASGI callable as a module-level variable named ``application``.
|
| 5 |
+
|
| 6 |
+
For more information on this file, see
|
| 7 |
+
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
import os
|
| 11 |
+
|
| 12 |
+
from django.core.asgi import get_asgi_application
|
| 13 |
+
|
| 14 |
+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DjangoWeb.settings')
|
| 15 |
+
|
| 16 |
+
application = get_asgi_application()
|
DjangoWeb/DjangoWeb/settings.py
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Django settings for DjangoWeb project.
|
| 3 |
+
|
| 4 |
+
Generated by 'django-admin startproject' using Django 4.2.6.
|
| 5 |
+
|
| 6 |
+
For more information on this file, see
|
| 7 |
+
https://docs.djangoproject.com/en/4.2/topics/settings/
|
| 8 |
+
|
| 9 |
+
For the full list of settings and their values, see
|
| 10 |
+
https://docs.djangoproject.com/en/4.2/ref/settings/
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
|
| 15 |
+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
| 16 |
+
BASE_DIR = Path(__file__).resolve().parent.parent
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Quick-start development settings - unsuitable for production
|
| 20 |
+
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
| 21 |
+
|
| 22 |
+
# SECURITY WARNING: keep the secret key used in production secret!
|
| 23 |
+
SECRET_KEY = 'django-insecure-0*rq7^(=u=-$^4gxo525=(386go2u*0-u_qnry@n*=32rj=ep5'
|
| 24 |
+
|
| 25 |
+
# SECURITY WARNING: don't run with debug turned on in production!
|
| 26 |
+
DEBUG = True
|
| 27 |
+
|
| 28 |
+
ALLOWED_HOSTS = []
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# Application definition
|
| 32 |
+
|
| 33 |
+
INSTALLED_APPS = [
|
| 34 |
+
'django.contrib.admin',
|
| 35 |
+
'django.contrib.auth',
|
| 36 |
+
'django.contrib.contenttypes',
|
| 37 |
+
'django.contrib.sessions',
|
| 38 |
+
'django.contrib.messages',
|
| 39 |
+
'django.contrib.staticfiles',
|
| 40 |
+
'main',
|
| 41 |
+
'API',
|
| 42 |
+
]
|
| 43 |
+
|
| 44 |
+
MIDDLEWARE = [
|
| 45 |
+
'django.middleware.security.SecurityMiddleware',
|
| 46 |
+
'django.contrib.sessions.middleware.SessionMiddleware',
|
| 47 |
+
'django.middleware.common.CommonMiddleware',
|
| 48 |
+
'django.middleware.csrf.CsrfViewMiddleware',
|
| 49 |
+
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
| 50 |
+
'django.contrib.messages.middleware.MessageMiddleware',
|
| 51 |
+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
| 52 |
+
]
|
| 53 |
+
|
| 54 |
+
ROOT_URLCONF = 'DjangoWeb.urls'
|
| 55 |
+
|
| 56 |
+
TEMPLATES = [
|
| 57 |
+
{
|
| 58 |
+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
| 59 |
+
'DIRS': [],
|
| 60 |
+
'APP_DIRS': True,
|
| 61 |
+
'OPTIONS': {
|
| 62 |
+
'context_processors': [
|
| 63 |
+
'django.template.context_processors.debug',
|
| 64 |
+
'django.template.context_processors.request',
|
| 65 |
+
'django.contrib.auth.context_processors.auth',
|
| 66 |
+
'django.contrib.messages.context_processors.messages',
|
| 67 |
+
],
|
| 68 |
+
},
|
| 69 |
+
},
|
| 70 |
+
]
|
| 71 |
+
|
| 72 |
+
WSGI_APPLICATION = 'DjangoWeb.wsgi.application'
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
# Database
|
| 76 |
+
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
| 77 |
+
|
| 78 |
+
DATABASES = {
|
| 79 |
+
'default': {
|
| 80 |
+
'ENGINE': 'django.db.backends.sqlite3',
|
| 81 |
+
'NAME': BASE_DIR / 'db.sqlite3',
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
# Password validation
|
| 87 |
+
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
| 88 |
+
|
| 89 |
+
AUTH_PASSWORD_VALIDATORS = [
|
| 90 |
+
{
|
| 91 |
+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
| 101 |
+
},
|
| 102 |
+
]
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
# Internationalization
|
| 106 |
+
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
| 107 |
+
|
| 108 |
+
LANGUAGE_CODE = 'en-us'
|
| 109 |
+
|
| 110 |
+
TIME_ZONE = 'UTC'
|
| 111 |
+
|
| 112 |
+
USE_I18N = True
|
| 113 |
+
|
| 114 |
+
USE_TZ = True
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
# Static files (CSS, JavaScript, Images)
|
| 118 |
+
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
| 119 |
+
|
| 120 |
+
STATIC_URL = 'static/'
|
| 121 |
+
|
| 122 |
+
# Default primary key field type
|
| 123 |
+
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
| 124 |
+
|
| 125 |
+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DjangoWeb/DjangoWeb/urls.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
URL configuration for DjangoWeb project.
|
| 3 |
+
|
| 4 |
+
The `urlpatterns` list routes URLs to views. For more information please see:
|
| 5 |
+
https://docs.djangoproject.com/en/4.2/topics/http/urls/
|
| 6 |
+
Examples:
|
| 7 |
+
Function views
|
| 8 |
+
1. Add an import: from my_app import views
|
| 9 |
+
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
| 10 |
+
Class-based views
|
| 11 |
+
1. Add an import: from other_app.views import Home
|
| 12 |
+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
| 13 |
+
Including another URLconf
|
| 14 |
+
1. Import the include() function: from django.urls import include, path
|
| 15 |
+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
| 16 |
+
"""
|
| 17 |
+
from django.contrib import admin
|
| 18 |
+
from django.urls import path,include
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
urlpatterns = [
|
| 22 |
+
path('admin/', admin.site.urls),
|
| 23 |
+
path('',include("main.urls")),
|
| 24 |
+
path('api/',include("API.urls")),
|
| 25 |
+
]
|
DjangoWeb/DjangoWeb/wsgi.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
WSGI config for DjangoWeb project.
|
| 3 |
+
|
| 4 |
+
It exposes the WSGI callable as a module-level variable named ``application``.
|
| 5 |
+
|
| 6 |
+
For more information on this file, see
|
| 7 |
+
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
import os
|
| 11 |
+
|
| 12 |
+
from django.core.wsgi import get_wsgi_application
|
| 13 |
+
|
| 14 |
+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DjangoWeb.settings')
|
| 15 |
+
|
| 16 |
+
application = get_wsgi_application()
|
DjangoWeb/ModelLoader/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from .colgen1 import Colgen1
|
DjangoWeb/ModelLoader/basemodel.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from abc import ABC,abstractmethod
|
| 2 |
+
|
| 3 |
+
class ModelBaseClass(ABC):
|
| 4 |
+
@abstractmethod
|
| 5 |
+
def preprocess(self,names):
|
| 6 |
+
pass
|
| 7 |
+
|
| 8 |
+
@abstractmethod
|
| 9 |
+
def predict(self,names):
|
| 10 |
+
pass
|
| 11 |
+
|
| 12 |
+
@staticmethod
|
| 13 |
+
def colorToHex(colors):
|
| 14 |
+
hex_list=[]
|
| 15 |
+
for color in colors:
|
| 16 |
+
hex_list.append("#{:02X}{:02X}{:02X}".format(color[0],color[1],color[2]))
|
| 17 |
+
return hex_list
|
DjangoWeb/ModelLoader/colgen1.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import tensorflow as tf
|
| 2 |
+
import numpy as np
|
| 3 |
+
import json
|
| 4 |
+
from .basemodel import ModelBaseClass
|
| 5 |
+
|
| 6 |
+
class Colgen1(ModelBaseClass):
|
| 7 |
+
|
| 8 |
+
def __init__(self,model_dir):
|
| 9 |
+
self.model=tf.keras.models.load_model(model_dir+"model.h5",compile=False)
|
| 10 |
+
self.token_to_idx=json.load(open(model_dir+"token_to_idx.txt",'r'))
|
| 11 |
+
self.TOKENS=list(self.token_to_idx.keys())
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def tokenize(self,name):
|
| 15 |
+
""" tokenize single name """
|
| 16 |
+
return [self.token_to_idx[char] for char in name]
|
| 17 |
+
|
| 18 |
+
def one_hot_encode(self,tokens,num_classes):
|
| 19 |
+
return tf.keras.utils.to_categorical(tokens,num_classes=num_classes)
|
| 20 |
+
|
| 21 |
+
def add_padding(self,one_hot_vectors,num_classes,max_num_tokens):
|
| 22 |
+
''' one_hot_vectors:np.array shape:(tokens,len(all_tokens)) '''
|
| 23 |
+
num_of_padding = max_num_tokens-len(one_hot_vectors)
|
| 24 |
+
padding = []
|
| 25 |
+
|
| 26 |
+
for _ in range(num_of_padding):
|
| 27 |
+
padding.append(np.zeros([num_classes]))
|
| 28 |
+
padding = np.array(padding)
|
| 29 |
+
|
| 30 |
+
return np.r_[padding,one_hot_vectors] if len(padding)>0 else one_hot_vectors
|
| 31 |
+
|
| 32 |
+
def preprocess(self,names):
|
| 33 |
+
""" names: [name,name,name,...] """
|
| 34 |
+
|
| 35 |
+
max_num_tokens=0
|
| 36 |
+
one_hots_list = []
|
| 37 |
+
|
| 38 |
+
for name in names:
|
| 39 |
+
name = name.lower()
|
| 40 |
+
tokens = self.tokenize(name)
|
| 41 |
+
one_hot_vectors = self.one_hot_encode(tokens,len(self.TOKENS))
|
| 42 |
+
if len(tokens)>max_num_tokens: max_num_tokens=len(tokens)
|
| 43 |
+
one_hots_list.append(one_hot_vectors)
|
| 44 |
+
|
| 45 |
+
for i in range(len(one_hots_list)):
|
| 46 |
+
# we need to add padding so that all the examples have same number of tokens
|
| 47 |
+
one_hots = one_hots_list[i]
|
| 48 |
+
one_hots_list[i] = self.add_padding(one_hots,len(self.TOKENS),max_num_tokens)
|
| 49 |
+
|
| 50 |
+
return np.array(one_hots_list)
|
| 51 |
+
|
| 52 |
+
def predict(self,names: list):
|
| 53 |
+
tokens = self.preprocess(names)
|
| 54 |
+
colors = (self.model.predict(tokens,verbose=0)*255).astype("uint8")
|
| 55 |
+
return colors
|
DjangoWeb/main/__init__.py
ADDED
|
File without changes
|
DjangoWeb/main/admin.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.contrib import admin
|
| 2 |
+
|
| 3 |
+
# Register your models here.
|
DjangoWeb/main/apps.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.apps import AppConfig
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class MainConfig(AppConfig):
|
| 5 |
+
default_auto_field = 'django.db.models.BigAutoField'
|
| 6 |
+
name = 'main'
|
DjangoWeb/main/migrations/__init__.py
ADDED
|
File without changes
|
DjangoWeb/main/models.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.db import models
|
| 2 |
+
|
| 3 |
+
# Create your models here.
|
DjangoWeb/main/static/main/index.css
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*{
|
| 2 |
+
margin:0;
|
| 3 |
+
padding:0;
|
| 4 |
+
box-sizing: border-box;
|
| 5 |
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
| 6 |
+
}
|
| 7 |
+
html,body{
|
| 8 |
+
min-height:100%;
|
| 9 |
+
width:100%;
|
| 10 |
+
background: linear-gradient(45deg ,#333399,#a9ff00);
|
| 11 |
+
}
|
| 12 |
+
body{
|
| 13 |
+
position: absolute;
|
| 14 |
+
top:0;
|
| 15 |
+
left:0;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
#main_container{
|
| 19 |
+
background-color: #ffffff4d;
|
| 20 |
+
box-shadow: 1px 1px 20px -10px #000;
|
| 21 |
+
/* height:100%; */
|
| 22 |
+
margin: 1.2rem;
|
| 23 |
+
padding: 1.5rem;
|
| 24 |
+
border-radius: 30px;
|
| 25 |
+
display: flex;
|
| 26 |
+
flex-direction: column;
|
| 27 |
+
align-items: center;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
h2{
|
| 31 |
+
width: fit-content;
|
| 32 |
+
margin-inline: auto ;
|
| 33 |
+
font-size:2rem;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
#search_section{
|
| 37 |
+
margin:4rem 0;
|
| 38 |
+
font-size:2rem;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
#search_input{
|
| 42 |
+
outline:none;
|
| 43 |
+
border:none;
|
| 44 |
+
border-bottom: 2px solid #000;
|
| 45 |
+
font-size:inherit;
|
| 46 |
+
background-color: transparent;
|
| 47 |
+
padding:0.3rem;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
input[type='button']{
|
| 51 |
+
outline:none;
|
| 52 |
+
border:none;
|
| 53 |
+
background-color: rgba(255, 255, 255, 0.537);
|
| 54 |
+
color:#000;
|
| 55 |
+
padding:1em;
|
| 56 |
+
font-size:1rem;
|
| 57 |
+
border-radius:10px;
|
| 58 |
+
}
|
| 59 |
+
input[type='button']:hover{
|
| 60 |
+
cursor: pointer;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
#colors_section{
|
| 66 |
+
width:100%;
|
| 67 |
+
display: flex;
|
| 68 |
+
flex-direction: row;
|
| 69 |
+
align-items: center;
|
| 70 |
+
justify-content: space-evenly;
|
| 71 |
+
flex-wrap: wrap;
|
| 72 |
+
}
|
| 73 |
+
.card{
|
| 74 |
+
height: 200px;
|
| 75 |
+
width: 150px;
|
| 76 |
+
background-color: #fff;
|
| 77 |
+
border-radius: 10px;
|
| 78 |
+
overflow: hidden;
|
| 79 |
+
margin:1em;
|
| 80 |
+
}
|
| 81 |
+
.card-color{
|
| 82 |
+
height:80%;
|
| 83 |
+
width: 100%;
|
| 84 |
+
background-color: #000;
|
| 85 |
+
position: relative;
|
| 86 |
+
}
|
| 87 |
+
.card-title{
|
| 88 |
+
height:20%;
|
| 89 |
+
display: flex;
|
| 90 |
+
align-items: center;
|
| 91 |
+
justify-content: center;
|
| 92 |
+
text-align: center;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.card-like-btn{
|
| 96 |
+
color: red;
|
| 97 |
+
font-size:2rem;
|
| 98 |
+
position: absolute;
|
| 99 |
+
bottom: 10px;
|
| 100 |
+
right:10px;
|
| 101 |
+
visibility: hidden;
|
| 102 |
+
}
|
| 103 |
+
.card-copy-btn{
|
| 104 |
+
color: white;
|
| 105 |
+
font-size:2rem;
|
| 106 |
+
position: absolute;
|
| 107 |
+
bottom: 10px;
|
| 108 |
+
left:10px;
|
| 109 |
+
visibility: hidden;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.card:hover{
|
| 113 |
+
.card-copy-btn{
|
| 114 |
+
visibility: visible;
|
| 115 |
+
}
|
| 116 |
+
.card-like-btn{
|
| 117 |
+
visibility: visible;
|
| 118 |
+
}
|
| 119 |
+
.card-copy-btn:hover,.card-like-btn:hover{
|
| 120 |
+
cursor: pointer;
|
| 121 |
+
}
|
| 122 |
+
}
|
DjangoWeb/main/static/main/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function createColorCard(colorname,color){
|
| 2 |
+
/*
|
| 3 |
+
<div class="card">
|
| 4 |
+
<div class="card-color">
|
| 5 |
+
|
| 6 |
+
<i class="fa-solid fa-copy card-copy-btn"></i>
|
| 7 |
+
<i class="fa-solid fa-heart card-like-btn"></i>
|
| 8 |
+
</div>
|
| 9 |
+
<div class="card-title">cool red</div>
|
| 10 |
+
</div>
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
card = document.createElement("div");
|
| 14 |
+
card.className = "card";
|
| 15 |
+
card.dataset.color=color;
|
| 16 |
+
card.innerHTML=`
|
| 17 |
+
<div class="card-color" style='background:${color}'>
|
| 18 |
+
<i class="fa-solid fa-copy card-copy-btn" onclick="copyToClipboard(this.closest('.card').dataset.color)"></i>
|
| 19 |
+
<i class="fa-solid fa-heart card-like-btn"></i>
|
| 20 |
+
</div>
|
| 21 |
+
<div class="card-title">${colorname}</div>
|
| 22 |
+
`;
|
| 23 |
+
|
| 24 |
+
colors_section.prepend(card);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
// createColorCard("blue");
|
| 28 |
+
// createColorCard("red");
|
| 29 |
+
// createColorCard("green");
|
| 30 |
+
// createColorCard("blue");
|
| 31 |
+
// createColorCard("red");
|
| 32 |
+
// createColorCard("green");
|
| 33 |
+
|
| 34 |
+
function generateColor(){
|
| 35 |
+
color_name = search_input.value.trim();
|
| 36 |
+
if(color_name=="") return;
|
| 37 |
+
if(color_name.length>200) return;
|
| 38 |
+
|
| 39 |
+
data = {
|
| 40 |
+
"color_names":[color_name],
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
header = {
|
| 44 |
+
"Content-Type":"application/json",
|
| 45 |
+
// "X-CSRFToken":csrf_token,
|
| 46 |
+
};
|
| 47 |
+
|
| 48 |
+
fetch("api/generate",{
|
| 49 |
+
method:"POST",
|
| 50 |
+
headers:header,
|
| 51 |
+
body:JSON.stringify(data),
|
| 52 |
+
}).then(response=>response.json()).then((res)=>{
|
| 53 |
+
// create card for it
|
| 54 |
+
createColorCard(color_name,res['colors'][0]);
|
| 55 |
+
})
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
function copyToClipboard(value){
|
| 59 |
+
navigator.clipboard.writeText(value);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
function detectOnSubmit(e){
|
| 63 |
+
if(e.key==='Enter' || e.keyCode===13)
|
| 64 |
+
generateColor()
|
| 65 |
+
}
|
DjangoWeb/main/templates/main/index.html
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
{% load static %}
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
+
<title>Imagine Color</title>
|
| 8 |
+
<link rel="stylesheet" href="{% static 'main/index.css' %}">
|
| 9 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
| 10 |
+
</head>
|
| 11 |
+
<body>
|
| 12 |
+
<div id="main_container">
|
| 13 |
+
<h2>Imagine Color</h2>
|
| 14 |
+
|
| 15 |
+
<section id="search_section">
|
| 16 |
+
<input type="text" id="search_input" onkeyup="detectOnSubmit(event)">
|
| 17 |
+
<input type="button" id="generate_btn" value="Generate" onclick="generateColor()">
|
| 18 |
+
<!-- <input type="button" id="search_btn" value="Search" disabled> -->
|
| 19 |
+
</section>
|
| 20 |
+
|
| 21 |
+
<section id="colors_section"></section>
|
| 22 |
+
</div>
|
| 23 |
+
</body>
|
| 24 |
+
|
| 25 |
+
<script src="{% static 'main/index.js' %}"></script>
|
| 26 |
+
</html>
|
DjangoWeb/main/tests.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.test import TestCase
|
| 2 |
+
|
| 3 |
+
# Create your tests here.
|
DjangoWeb/main/urls.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.urls import path
|
| 2 |
+
from . import views
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
urlpatterns = [
|
| 6 |
+
path('',views.home),
|
| 7 |
+
]
|
DjangoWeb/main/views.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpResponse
|
| 2 |
+
from django.shortcuts import render
|
| 3 |
+
|
| 4 |
+
def home(request):
|
| 5 |
+
# return HttpResponse("heyyy")
|
| 6 |
+
return render(request,"main/index.html",context={})
|
DjangoWeb/manage.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
"""Django's command-line utility for administrative tasks."""
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def main():
|
| 8 |
+
"""Run administrative tasks."""
|
| 9 |
+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DjangoWeb.settings')
|
| 10 |
+
try:
|
| 11 |
+
from django.core.management import execute_from_command_line
|
| 12 |
+
except ImportError as exc:
|
| 13 |
+
raise ImportError(
|
| 14 |
+
"Couldn't import Django. Are you sure it's installed and "
|
| 15 |
+
"available on your PYTHONPATH environment variable? Did you "
|
| 16 |
+
"forget to activate a virtual environment?"
|
| 17 |
+
) from exc
|
| 18 |
+
execute_from_command_line(sys.argv)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
if __name__ == '__main__':
|
| 22 |
+
main()
|
DjangoWeb/requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Django==4.2.6
|
| 2 |
+
numpy==1.24.3
|
| 3 |
+
tensorflow
|
Dockerfile
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FROM python:3.11-bullseye
|
| 2 |
+
FROM tensorflow/tensorflow
|
| 3 |
+
# FROM ubuntu
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
# RUN apt-get update && \
|
| 7 |
+
# apt-get -y upgrade && \
|
| 8 |
+
# apt-get install -y \
|
| 9 |
+
# sudo
|
| 10 |
+
|
| 11 |
+
# RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python3 pip vim mc wget curl
|
| 12 |
+
|
| 13 |
+
# # to make open-cv work
|
| 14 |
+
# RUN apt-get install ffmpeg libsm6 libxext6 -y
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
EXPOSE 8000
|
| 19 |
+
COPY ./DjangoWeb/ /app
|
| 20 |
+
WORKDIR /app
|
| 21 |
+
RUN pip install --upgrade pip
|
| 22 |
+
RUN pip install -r requirements.txt --no-cache-dir
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
# RUN rm db.sqlite3
|
| 26 |
+
RUN ls -lh
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
# RUN python3 manage.py makemigrations;\
|
| 30 |
+
# python3 manage.py migrate;
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
# Make app folder writeable for the sake of db.sqlite3, and make that file also writeable.
|
| 34 |
+
# Ideally you host the database somewhere else so that the app folders can remain read only.
|
| 35 |
+
# Without these permissions you see the errors "unable to open database file" and
|
| 36 |
+
# "attempt to write to a readonly database", respectively, whenever the app attempts to
|
| 37 |
+
# write to the database.
|
| 38 |
+
RUN chmod g+w /app;
|
| 39 |
+
# RUN chmod g+w /app/db.sqlite3;
|
| 40 |
+
# upper commands are working !
|
| 41 |
+
|
| 42 |
+
RUN ls -lh
|
| 43 |
+
|
| 44 |
+
CMD python3 manage.py runserver 0.0.0.0:8000
|
README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Imagine Color
|
| 3 |
+
emoji: 🏃
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: yellow
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
app_port: 8000
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Imagine-Color
|
| 12 |
+
|
| 13 |
+
An RNN based model which is used to generate color from text.
|
| 14 |
+
|
| 15 |
+
## Some Guidelines for the Project:-
|
| 16 |
+
|
| 17 |
+
- Ensure to write well structured and readable code.
|
| 18 |
+
|
| 19 |
+
## Models:-
|
| 20 |
+
|
| 21 |
+
- [X] Make a simple Model (**colgen-1**)
|
| 22 |
+
- Make it based on character level tokenization
|
| 23 |
+
- [ ] Model with word-embedding (**colgen-2**)
|
| 24 |
+
- Make it based on word level tokenization
|
| 25 |
+
- don't use precalculated word embeddings
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
## Web UI
|
| 30 |
+
|
| 31 |
+
- [X] Basic UI
|
| 32 |
+
- [X] Generate Color Functionality
|
| 33 |
+
- [ ] Save old color which are liked
|
| 34 |
+
- [ ] Add search functionality
|
| 35 |
+
- [ ] Add API endpoints
|
| 36 |
+
- [ ] Add API Documentation
|
| 37 |
+
- [ ] Add option to select which model to use
|
test.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ModelLoader import Colgen1
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
model_dir="models/colgen1/"
|
| 6 |
+
model=Colgen1(model_dir)
|
| 7 |
+
|
| 8 |
+
out=model.predict(['Red','green','blue','yellow'])
|
| 9 |
+
print(out)
|
wordtorgb(word2vec).ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|