Spaces:
Runtime error
Runtime error
Commit
·
c65fc1f
0
Parent(s):
init commit
Browse filesSigned-off-by: AnyISalIn <[email protected]>
- .gitignore +161 -0
- Dockerfile +9 -0
- app.py +405 -0
- examples/newton_man/newton_0.jpg +0 -0
- examples/newton_man/newton_1.jpg +0 -0
- examples/newton_man/newton_3.jpg +0 -0
- examples/scarletthead_woman/scarlett_0.jpg +0 -0
- examples/scarletthead_woman/scarlett_1.jpg +0 -0
- examples/scarletthead_woman/scarlett_2.jpg +0 -0
- examples/scarletthead_woman/scarlett_3.jpg +0 -0
- requirements.txt +2 -0
- style_template.py +59 -0
.gitignore
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
share/python-wheels/
|
24 |
+
*.egg-info/
|
25 |
+
.installed.cfg
|
26 |
+
*.egg
|
27 |
+
MANIFEST
|
28 |
+
|
29 |
+
# PyInstaller
|
30 |
+
# Usually these files are written by a python script from a template
|
31 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
32 |
+
*.manifest
|
33 |
+
*.spec
|
34 |
+
|
35 |
+
# Installer logs
|
36 |
+
pip-log.txt
|
37 |
+
pip-delete-this-directory.txt
|
38 |
+
|
39 |
+
# Unit test / coverage reports
|
40 |
+
htmlcov/
|
41 |
+
.tox/
|
42 |
+
.nox/
|
43 |
+
.coverage
|
44 |
+
.coverage.*
|
45 |
+
.cache
|
46 |
+
nosetests.xml
|
47 |
+
coverage.xml
|
48 |
+
*.cover
|
49 |
+
*.py,cover
|
50 |
+
.hypothesis/
|
51 |
+
.pytest_cache/
|
52 |
+
cover/
|
53 |
+
|
54 |
+
# Translations
|
55 |
+
*.mo
|
56 |
+
*.pot
|
57 |
+
|
58 |
+
# Django stuff:
|
59 |
+
*.log
|
60 |
+
local_settings.py
|
61 |
+
db.sqlite3
|
62 |
+
db.sqlite3-journal
|
63 |
+
|
64 |
+
# Flask stuff:
|
65 |
+
instance/
|
66 |
+
.webassets-cache
|
67 |
+
|
68 |
+
# Scrapy stuff:
|
69 |
+
.scrapy
|
70 |
+
|
71 |
+
# Sphinx documentation
|
72 |
+
docs/_build/
|
73 |
+
|
74 |
+
# PyBuilder
|
75 |
+
.pybuilder/
|
76 |
+
target/
|
77 |
+
|
78 |
+
# Jupyter Notebook
|
79 |
+
.ipynb_checkpoints
|
80 |
+
|
81 |
+
# IPython
|
82 |
+
profile_default/
|
83 |
+
ipython_config.py
|
84 |
+
|
85 |
+
# pyenv
|
86 |
+
# For a library or package, you might want to ignore these files since the code is
|
87 |
+
# intended to run in multiple environments; otherwise, check them in:
|
88 |
+
# .python-version
|
89 |
+
|
90 |
+
# pipenv
|
91 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
92 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
93 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
94 |
+
# install all needed dependencies.
|
95 |
+
#Pipfile.lock
|
96 |
+
|
97 |
+
# poetry
|
98 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
99 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
100 |
+
# commonly ignored for libraries.
|
101 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
102 |
+
#poetry.lock
|
103 |
+
|
104 |
+
# pdm
|
105 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
106 |
+
#pdm.lock
|
107 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
108 |
+
# in version control.
|
109 |
+
# https://pdm.fming.dev/#use-with-ide
|
110 |
+
.pdm.toml
|
111 |
+
|
112 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
113 |
+
__pypackages__/
|
114 |
+
|
115 |
+
# Celery stuff
|
116 |
+
celerybeat-schedule
|
117 |
+
celerybeat.pid
|
118 |
+
|
119 |
+
# SageMath parsed files
|
120 |
+
*.sage.py
|
121 |
+
|
122 |
+
# Environments
|
123 |
+
.env
|
124 |
+
.venv
|
125 |
+
env/
|
126 |
+
venv/
|
127 |
+
ENV/
|
128 |
+
env.bak/
|
129 |
+
venv.bak/
|
130 |
+
|
131 |
+
# Spyder project settings
|
132 |
+
.spyderproject
|
133 |
+
.spyproject
|
134 |
+
|
135 |
+
# Rope project settings
|
136 |
+
.ropeproject
|
137 |
+
|
138 |
+
# mkdocs documentation
|
139 |
+
/site
|
140 |
+
|
141 |
+
# mypy
|
142 |
+
.mypy_cache/
|
143 |
+
.dmypy.json
|
144 |
+
dmypy.json
|
145 |
+
|
146 |
+
# Pyre type checker
|
147 |
+
.pyre/
|
148 |
+
|
149 |
+
# pytype static type analyzer
|
150 |
+
.pytype/
|
151 |
+
|
152 |
+
# Cython debug symbols
|
153 |
+
cython_debug/
|
154 |
+
|
155 |
+
# PyCharm
|
156 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
157 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
158 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
159 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
160 |
+
#.idea/
|
161 |
+
tests/data
|
Dockerfile
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.11.1
|
2 |
+
|
3 |
+
COPY . /app
|
4 |
+
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
RUN pip install -r requirements.txt
|
8 |
+
|
9 |
+
CMD ["python", "app.py"]
|
app.py
ADDED
@@ -0,0 +1,405 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
import os
|
3 |
+
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
from style_template import styles
|
7 |
+
from novita_client import NovitaClient, MakePhotoLoRA
|
8 |
+
|
9 |
+
from PIL import Image
|
10 |
+
import base64
|
11 |
+
from io import BytesIO
|
12 |
+
|
13 |
+
# global variable
|
14 |
+
MAX_SEED = 2 ** 32 - 1
|
15 |
+
STYLE_NAMES = list(styles.keys())
|
16 |
+
DEFAULT_STYLE_NAME = "Photographic (Default)"
|
17 |
+
|
18 |
+
|
19 |
+
def get_noviata_client(novita_key):
|
20 |
+
client = NovitaClient(novita_key, os.getenv('NOVITA_API_URI', None))
|
21 |
+
return client
|
22 |
+
|
23 |
+
|
24 |
+
get_local_storage = """
|
25 |
+
function() {
|
26 |
+
globalThis.setStorage = (key, value)=>{
|
27 |
+
localStorage.setItem(key, JSON.stringify(value))
|
28 |
+
}
|
29 |
+
globalThis.getStorage = (key, value)=>{
|
30 |
+
return JSON.parse(localStorage.getItem(key))
|
31 |
+
}
|
32 |
+
|
33 |
+
const novita_key = getStorage('novita_key')
|
34 |
+
return [novita_key];
|
35 |
+
}
|
36 |
+
"""
|
37 |
+
|
38 |
+
|
39 |
+
sdxl_models = ["albedobaseXL_v04_130099.safetensors",
|
40 |
+
"altxl_v60_146691.safetensors",
|
41 |
+
"animeArtDiffusionXL_alpha2_91872.safetensors",
|
42 |
+
"animeArtDiffusionXL_alpha3_93120.safetensors",
|
43 |
+
"animeIllustDiffusion_v04_117809.safetensors",
|
44 |
+
"breakdomainxl_V05g_124265.safetensors",
|
45 |
+
"brixlAMustInYour_v40Dagobah_145992.safetensors",
|
46 |
+
"cinemaxAlphaSDXLCinema_alpha1_107473.safetensors",
|
47 |
+
"cineroXLPhotomatic_v12aPHENO_137703.safetensors",
|
48 |
+
"clearhungAnimeXL_v10_117716.safetensors",
|
49 |
+
"copaxTimelessxlSDXL1_colorfulV2_100729.safetensors",
|
50 |
+
"counterfeitxl__98184.safetensors",
|
51 |
+
"counterfeitxl_v10_108721.safetensors",
|
52 |
+
"crystalClearXL_ccxl_97637.safetensors",
|
53 |
+
"dreamshaperXL09Alpha_alpha2Xl10_91562.safetensors",
|
54 |
+
"dynavisionXLAllInOneStylized_alpha036FP16Bakedvae_99980.safetensors",
|
55 |
+
"dynavisionXLAllInOneStylized_beta0411Bakedvae_109970.safetensors",
|
56 |
+
"dynavisionXLAllInOneStylized_release0534bakedvae_129001.safetensors",
|
57 |
+
"fenrisxl_145_134980.safetensors",
|
58 |
+
"foddaxlPhotorealism_v45_122788.safetensors",
|
59 |
+
"formulaxl_v10_104889.safetensors",
|
60 |
+
"juggernautXL_version2_113240.safetensors",
|
61 |
+
"juggernautXL_version5_126522.safetensors",
|
62 |
+
"kohakuXL_alpha7_111843.safetensors",
|
63 |
+
"LahMysteriousSDXL_v40_122478.safetensors",
|
64 |
+
"leosamsHelloworldSDXLModel_helloworldSDXL10_112178.safetensors",
|
65 |
+
"mbbxlUltimate_v10RC_94686.safetensors",
|
66 |
+
"moefusionSDXL_v10_114018.safetensors",
|
67 |
+
"nightvisionXLPhotorealisticPortrait_beta0681Bakedvae_108833.safetensors",
|
68 |
+
"nightvisionXLPhotorealisticPortrait_beta0702Bakedvae_113098.safetensors",
|
69 |
+
"nightvisionXLPhotorealisticPortrait_release0770Bakedvae_154525.safetensors",
|
70 |
+
"novaPrimeXL_v10_107899.safetensors",
|
71 |
+
"pixelwave_v10_117722.safetensors",
|
72 |
+
"protovisionXLHighFidelity3D_beta0520Bakedvae_106612.safetensors",
|
73 |
+
"protovisionXLHighFidelity3D_release0620Bakedvae_131308.safetensors",
|
74 |
+
"protovisionXLHighFidelity3D_release0630Bakedvae_154359.safetensors",
|
75 |
+
"realismEngineSDXL_v05b_131513.safetensors",
|
76 |
+
"realismEngineSDXL_v10_136287.safetensors",
|
77 |
+
"realisticStockPhoto_v10_115618.safetensors",
|
78 |
+
"RealitiesEdgeXL_4_122673.safetensors",
|
79 |
+
"realvisxlV20_v20Bakedvae_129156.safetensors",
|
80 |
+
"riotDiffusionXL_v20_139293.safetensors",
|
81 |
+
"roxl_v10_109354.safetensors",
|
82 |
+
"sd_xl_base_0.9.safetensors",
|
83 |
+
"sd_xl_base_1.0.safetensors",
|
84 |
+
"sdxlNijiSpecial_sdxlNijiSE_115638.safetensors",
|
85 |
+
"sdxlNijiV3_sdxlNijiV3_104571.safetensors",
|
86 |
+
"sdxlNijiV51_sdxlNijiV51_112807.safetensors",
|
87 |
+
"sd_xl_refiner_1.0.safetensors",
|
88 |
+
"sdxlUnstableDiffusers_v8HEAVENSWRATH_133813.safetensors",
|
89 |
+
"sdXL_v10Refiner_91495.safetensors",
|
90 |
+
"sdxlYamersAnimeUltra_yamersAnimeV3_121537.safetensors",
|
91 |
+
"shikianimexl_v10_93788.safetensors",
|
92 |
+
"stable-diffusion-xl-1.0-inpainting-0.1.safetensors",
|
93 |
+
"stable-diffusion-xl-base-1.0.safetensors",
|
94 |
+
"theTalosProject_v10_117893.safetensors",
|
95 |
+
"thinkdiffusionxl_v10_145931.safetensors",
|
96 |
+
"protovisionXLHighFidelity3D_releaseV660Bakedvae_207131.safetensors",
|
97 |
+
"voidnoisecorexl_r1486_150780.safetensors",
|
98 |
+
"wlopArienwlopstylexl_v10_101973.safetensors",
|
99 |
+
"wlopSTYLEXL_v2_126171.safetensors",
|
100 |
+
"xl13AsmodeusSFWNSFW_v22BakedVAE_111954.safetensors",
|
101 |
+
"xxmix9realisticsdxl_v10_123235.safetensors",
|
102 |
+
"zavychromaxl_b2_103298.safetensors",
|
103 |
+
"zavychromaxl_v21_129006.safetensors"]
|
104 |
+
sdxl_loras = ['sdxl_wrong_lora.safetensors',
|
105 |
+
'SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4_139125.safetensors',
|
106 |
+
'RMSDXL_Darkness_Cinema_211126.safetensors',
|
107 |
+
'ASH_230253.safetensors',
|
108 |
+
'xl_more_art-full_v1_113467.safetensors',
|
109 |
+
'add-detail-xl_99264.safetensors',
|
110 |
+
'Kodak Motion Picture Film Style3_222549.safetensors',
|
111 |
+
'JuggerCineXL2_95870.safetensors',
|
112 |
+
'AST_229222.safetensors',
|
113 |
+
'NsfwPovAllInOneLoraSdxl-000009_120561.safetensors',
|
114 |
+
'LCM_LoRA_Weights_169352.safetensors',
|
115 |
+
'Cinematic_Painting_XL_V02_151050.safetensors',
|
116 |
+
'SDXLHighDetail_v5_107780.safetensors',
|
117 |
+
'p1c4ss0_003-step00028000_140158.safetensors',
|
118 |
+
'RMSDXL_Enhance_209720.safetensors',
|
119 |
+
'DI_belle_delphine_sdxl_v1_93586.safetensors',
|
120 |
+
'LogoRedmondV2-Logo-LogoRedmAF_135681.safetensors',
|
121 |
+
'AnalogRedmondV2-Analog-AnalogRedmAF_135776.safetensors',
|
122 |
+
'csal_scenery_XL_106371.safetensors',
|
123 |
+
'Holography_140985.safetensors',
|
124 |
+
'SDXL_cinematic_Sa_May_151691.safetensors',
|
125 |
+
'BoutXOval_SDXL_dim32-000005_92430.safetensors',
|
126 |
+
'chahua_137600.safetensors',
|
127 |
+
'Macpaint-XL-000015_131908.safetensors',
|
128 |
+
'fdec_140071.safetensors',
|
129 |
+
'landscape-painting-sdxl_v2_111037.safetensors',
|
130 |
+
'SDXL-Emoji-Lora-r4_120592.safetensors',
|
131 |
+
'vncnt_144477.safetensors',
|
132 |
+
'Digital_Madness_139496.safetensors',
|
133 |
+
'Aether_Glitch_v1_LoRA_128844.safetensors',
|
134 |
+
'flat_chested_with_top-v0.9_141431.safetensors',
|
135 |
+
'fr4z3tt4_94108.safetensors',
|
136 |
+
'cute girl_104277.safetensors',
|
137 |
+
'SDXL_MSPaint_Portrait_157817.safetensors',
|
138 |
+
'Storyboard_sketch_140144.safetensors',
|
139 |
+
'3l3ctronics-step00003000_126441.safetensors',
|
140 |
+
'sdxl_glass_136034.safetensors',
|
141 |
+
'sd_xl_dpo_lora_v1_214128.safetensors',
|
142 |
+
'Crayon_Drawing_159195.safetensors',
|
143 |
+
'concept_pov_dt_xl2-000020_119643.safetensors',
|
144 |
+
'SDXLGhostStyle_145763.safetensors',
|
145 |
+
'polyhedron_all_sdxl-000004_110557.safetensors',
|
146 |
+
'xl_yoshiaki_kawajiri_v1r64_126468.safetensors',
|
147 |
+
'Lines_Clothes_XL_138401.safetensors',
|
148 |
+
'sdxl_cute_social_comic-000002_107980.safetensors',
|
149 |
+
'Graphic_Portrait_146112.safetensors',
|
150 |
+
'FF-Halloween-Full_154412.safetensors',
|
151 |
+
'Candy_land_2_141469.safetensors',
|
152 |
+
'acidzlime-sdxl_154149.safetensors',
|
153 |
+
'NsfwPovAllInOneLoraSdxl-000009MINI_120545.safetensors',
|
154 |
+
'sdxl_liminal_v1-step00003000_105309.safetensors',
|
155 |
+
'Cute Animals_114772.safetensors',
|
156 |
+
'ral-beer-sdxl_235173.safetensors',
|
157 |
+
'JoeyKingSDXL_201358.safetensors',
|
158 |
+
'SDXLFrosted_191661.safetensors',
|
159 |
+
'gardevoir-000017_101442.safetensors',
|
160 |
+
'Graphic_140518.safetensors',
|
161 |
+
'TShirtDesignRedmondV2-Tshirtdesign-TshirtDesignAF_136145.safetensors',
|
162 |
+
'Film Stock Footage Style_235607.safetensors',
|
163 |
+
'ral-wtchz-sdxl_233487.safetensors',
|
164 |
+
'Pussy_pants_nohands_D03_realvizXL2_bucket_01-000010_200586.safetensors',
|
165 |
+
'cinematic vintage film_165734.safetensors',
|
166 |
+
'epoxy_skull-sdxl_153213.safetensors']
|
167 |
+
|
168 |
+
|
169 |
+
def generate_image(novita_key, upload_images, checkpoint, lora_name, lora_strength, width, height, prompt, style_name, negative_prompt, num_steps, style_strength_ratio, num_outputs, guidance_scale, seed):
|
170 |
+
prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
|
171 |
+
|
172 |
+
if upload_images is None:
|
173 |
+
raise gr.Error(f"Cannot find any input face image! Please refer to step 1️⃣")
|
174 |
+
|
175 |
+
loras = []
|
176 |
+
if lora_name:
|
177 |
+
loras.append(
|
178 |
+
MakePhotoLoRA(
|
179 |
+
model_name=lora_name,
|
180 |
+
strength=lora_strength
|
181 |
+
)
|
182 |
+
)
|
183 |
+
|
184 |
+
try:
|
185 |
+
res = get_noviata_client(novita_key).make_photo(
|
186 |
+
model_name=checkpoint,
|
187 |
+
prompt=prompt,
|
188 |
+
negative_prompt=negative_prompt,
|
189 |
+
images=[_.name for _ in upload_images],
|
190 |
+
loras=loras,
|
191 |
+
steps=num_steps,
|
192 |
+
height=height,
|
193 |
+
width=width,
|
194 |
+
guidance_scale=guidance_scale,
|
195 |
+
strength=style_strength_ratio / 100,
|
196 |
+
seed=seed,
|
197 |
+
image_num=num_outputs,
|
198 |
+
)
|
199 |
+
except Exception as e:
|
200 |
+
raise gr.Error(f"Error: {e}")
|
201 |
+
|
202 |
+
images = [Image.open(BytesIO(base64.b64decode(res.images_encoded[idx]))) for idx in range(len(res.images_encoded))]
|
203 |
+
|
204 |
+
return images, {
|
205 |
+
"model_name": checkpoint,
|
206 |
+
"prompt": prompt,
|
207 |
+
"negative_prompt": negative_prompt,
|
208 |
+
"images": [_.name for _ in upload_images],
|
209 |
+
"loras": loras,
|
210 |
+
"steps": num_steps,
|
211 |
+
"height": height,
|
212 |
+
"width": width,
|
213 |
+
"guidance_scale": guidance_scale,
|
214 |
+
"strength": style_strength_ratio / 100,
|
215 |
+
"seed": seed,
|
216 |
+
"image_num": num_outputs,
|
217 |
+
}
|
218 |
+
|
219 |
+
|
220 |
+
def swap_to_gallery(images):
|
221 |
+
return gr.update(value=images, visible=True), gr.update(visible=True), gr.update(visible=False)
|
222 |
+
|
223 |
+
|
224 |
+
def upload_example_to_gallery(images, checkpoint, lora_name, lora_strength, width, height, prompt, style, negative_prompt):
|
225 |
+
return gr.update(value=[_.name for _ in images], visible=True), gr.update(value=checkpoint), gr.update(visible=True), gr.update(visible=False)
|
226 |
+
|
227 |
+
|
228 |
+
def remove_back_to_files():
|
229 |
+
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True)
|
230 |
+
|
231 |
+
|
232 |
+
def remove_tips():
|
233 |
+
return gr.update(visible=False)
|
234 |
+
|
235 |
+
|
236 |
+
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
237 |
+
if randomize_seed:
|
238 |
+
seed = random.randint(0, MAX_SEED)
|
239 |
+
return seed
|
240 |
+
|
241 |
+
|
242 |
+
def apply_style(style_name: str, positive: str, negative: str = "") -> tuple[str, str]:
|
243 |
+
p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
|
244 |
+
return p.replace("{prompt}", positive), n + ' ' + negative
|
245 |
+
|
246 |
+
|
247 |
+
def get_image_path_list(folder_name):
|
248 |
+
image_basename_list = os.listdir(folder_name)
|
249 |
+
image_path_list = sorted([os.path.join(folder_name, basename) for basename in image_basename_list])
|
250 |
+
return image_path_list
|
251 |
+
|
252 |
+
|
253 |
+
def get_example():
|
254 |
+
case = [
|
255 |
+
[
|
256 |
+
get_image_path_list('./examples/scarletthead_woman'),
|
257 |
+
"protovisionXLHighFidelity3D_releaseV660Bakedvae_207131.safetensors",
|
258 |
+
None,
|
259 |
+
None,
|
260 |
+
1024,
|
261 |
+
1024,
|
262 |
+
"instagram photo, portrait photo of a woman img, colorful, perfect face, natural skin, hard shadows, film grain",
|
263 |
+
"(No style)",
|
264 |
+
"(asymmetry, worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), open mouth",
|
265 |
+
],
|
266 |
+
[
|
267 |
+
get_image_path_list('./examples/newton_man'),
|
268 |
+
"protovisionXLHighFidelity3D_releaseV660Bakedvae_207131.safetensors",
|
269 |
+
None,
|
270 |
+
None,
|
271 |
+
1024,
|
272 |
+
1024,
|
273 |
+
"sci-fi, closeup portrait photo of a man img wearing the sunglasses in Iron man suit, face, slim body, high quality, film grain",
|
274 |
+
"(No style)",
|
275 |
+
"(asymmetry, worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), open mouth",
|
276 |
+
],
|
277 |
+
]
|
278 |
+
return case
|
279 |
+
|
280 |
+
|
281 |
+
with gr.Blocks() as demo:
|
282 |
+
# gr.DuplicateButton(
|
283 |
+
# value="Duplicate Space for private use ",
|
284 |
+
# elem_id="duplicate-button",
|
285 |
+
# visible=os.getenv("SHOW_DUPLICATE_BUTTON") == "1",
|
286 |
+
# )
|
287 |
+
with gr.Row():
|
288 |
+
with gr.Column(scale=1):
|
289 |
+
novita_key = gr.Textbox(value="", label="Novita.AI API KEY (store in broweser)", placeholder="novita.ai api key", type="password")
|
290 |
+
with gr.Column(scale=1):
|
291 |
+
user_balance = gr.Textbox(label="User Balance", value="0.0")
|
292 |
+
|
293 |
+
with gr.Row():
|
294 |
+
with gr.Column():
|
295 |
+
files = gr.Files(
|
296 |
+
label="Drag (Select) 1 or more photos of your face",
|
297 |
+
file_types=["image"]
|
298 |
+
)
|
299 |
+
uploaded_files = gr.Gallery(label="Your images", visible=False, columns=5, rows=1, height=200)
|
300 |
+
with gr.Column(visible=False) as clear_button:
|
301 |
+
remove_and_reupload = gr.ClearButton(value="Remove and upload new ones", components=files, size="sm")
|
302 |
+
checkpoint = gr.Dropdown(label="Checkpoint", choices=sdxl_models, value="RealVisXL_V3.0.safetensors", type="value")
|
303 |
+
lora_name = gr.Dropdown(label="LoRA", choices=sdxl_loras)
|
304 |
+
lora_strength = gr.Slider(label="LoRA strength", minimum=0.0, maximum=1.0, step=0.1, value=0.5)
|
305 |
+
height = gr.Slider(label="Height", minimum=256, maximum=2048, step=1, value=1024)
|
306 |
+
width = gr.Slider(label="Width", minimum=256, maximum=2048, step=1, value=1024)
|
307 |
+
|
308 |
+
prompt = gr.Textbox(label="Prompt",
|
309 |
+
info="Try something like 'a photo of a man/woman img', 'img' is the trigger word.",
|
310 |
+
placeholder="A photo of a [man/woman img]...")
|
311 |
+
style = gr.Dropdown(label="Style template", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME)
|
312 |
+
submit = gr.Button("Submit")
|
313 |
+
|
314 |
+
with gr.Accordion(open=False, label="Advanced Options"):
|
315 |
+
negative_prompt = gr.Textbox(
|
316 |
+
label="Negative Prompt",
|
317 |
+
placeholder="low quality",
|
318 |
+
value="nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",
|
319 |
+
)
|
320 |
+
num_steps = gr.Slider(
|
321 |
+
label="Number of sample steps",
|
322 |
+
minimum=20,
|
323 |
+
maximum=100,
|
324 |
+
step=1,
|
325 |
+
value=50,
|
326 |
+
)
|
327 |
+
style_strength_ratio = gr.Slider(
|
328 |
+
label="Style strength (%)",
|
329 |
+
minimum=15,
|
330 |
+
maximum=50,
|
331 |
+
step=1,
|
332 |
+
value=20,
|
333 |
+
)
|
334 |
+
num_outputs = gr.Slider(
|
335 |
+
label="Number of output images",
|
336 |
+
minimum=1,
|
337 |
+
maximum=4,
|
338 |
+
step=1,
|
339 |
+
value=1,
|
340 |
+
)
|
341 |
+
guidance_scale = gr.Slider(
|
342 |
+
label="Guidance scale",
|
343 |
+
minimum=0.1,
|
344 |
+
maximum=10.0,
|
345 |
+
step=0.1,
|
346 |
+
value=5,
|
347 |
+
)
|
348 |
+
seed = gr.Slider(
|
349 |
+
label="Seed",
|
350 |
+
minimum=0,
|
351 |
+
maximum=MAX_SEED,
|
352 |
+
step=1,
|
353 |
+
value=0,
|
354 |
+
)
|
355 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
356 |
+
with gr.Column():
|
357 |
+
gallery = gr.Gallery(label="Generated Images")
|
358 |
+
request_payload = gr.JSON(label="Request Payload")
|
359 |
+
|
360 |
+
files.upload(fn=swap_to_gallery, inputs=files, outputs=[uploaded_files, clear_button, files])
|
361 |
+
remove_and_reupload.click(fn=remove_back_to_files, outputs=[uploaded_files, clear_button, files])
|
362 |
+
|
363 |
+
submit.click(
|
364 |
+
fn=remove_tips,
|
365 |
+
).then(
|
366 |
+
fn=randomize_seed_fn,
|
367 |
+
inputs=[seed, randomize_seed],
|
368 |
+
outputs=seed,
|
369 |
+
queue=False,
|
370 |
+
api_name=False,
|
371 |
+
).then(
|
372 |
+
fn=generate_image,
|
373 |
+
inputs=[novita_key, files, checkpoint, lora_name, lora_strength, width, height, prompt, style, negative_prompt, num_steps, style_strength_ratio, num_outputs, guidance_scale, seed],
|
374 |
+
outputs=[gallery, request_payload]
|
375 |
+
)
|
376 |
+
|
377 |
+
gr.Examples(
|
378 |
+
examples=get_example(),
|
379 |
+
inputs=[files, checkpoint, lora_name, lora_strength, width, height, prompt, style, negative_prompt],
|
380 |
+
run_on_click=True,
|
381 |
+
fn=upload_example_to_gallery,
|
382 |
+
outputs=[uploaded_files, checkpoint, clear_button, files],
|
383 |
+
)
|
384 |
+
|
385 |
+
def onload(novita_key):
|
386 |
+
if novita_key is None or novita_key == "":
|
387 |
+
return novita_key, f"$ UNKNOWN", gr.update(visible=False)
|
388 |
+
try:
|
389 |
+
user_info_json = get_noviata_client(novita_key).user_info()
|
390 |
+
except Exception as e:
|
391 |
+
return novita_key, f"$ UNKNOWN"
|
392 |
+
|
393 |
+
return novita_key, f"$ {user_info_json.credit_balance / 100 / 100:.2f}"
|
394 |
+
|
395 |
+
novita_key.change(onload, inputs=novita_key, outputs=[novita_key, user_balance], _js="(v)=>{ setStorage('novita_key',v); return [v]; }")
|
396 |
+
|
397 |
+
demo.load(
|
398 |
+
inputs=[novita_key],
|
399 |
+
outputs=[novita_key, user_balance],
|
400 |
+
fn=onload,
|
401 |
+
_js=get_local_storage,
|
402 |
+
)
|
403 |
+
|
404 |
+
demo.queue(api_open=False, concurrency_count=20)
|
405 |
+
demo.launch(server_name="0.0.0.0", share=False)
|
examples/newton_man/newton_0.jpg
ADDED
![]() |
examples/newton_man/newton_1.jpg
ADDED
![]() |
examples/newton_man/newton_3.jpg
ADDED
![]() |
examples/scarletthead_woman/scarlett_0.jpg
ADDED
![]() |
examples/scarletthead_woman/scarlett_1.jpg
ADDED
![]() |
examples/scarletthead_woman/scarlett_2.jpg
ADDED
![]() |
examples/scarletthead_woman/scarlett_3.jpg
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
novita_client==0.4.12
|
2 |
+
gradio==3.50.2
|
style_template.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
style_list = [
|
2 |
+
{
|
3 |
+
"name": "(No style)",
|
4 |
+
"prompt": "{prompt}",
|
5 |
+
"negative_prompt": "",
|
6 |
+
},
|
7 |
+
{
|
8 |
+
"name": "Cinematic",
|
9 |
+
"prompt": "cinematic still {prompt} . emotional, harmonious, vignette, highly detailed, high budget, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy",
|
10 |
+
"negative_prompt": "anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured",
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"name": "Disney Charactor",
|
14 |
+
"prompt": "A Pixar animation character of {prompt} . pixar-style, studio anime, Disney, high-quality",
|
15 |
+
"negative_prompt": "lowres, bad anatomy, bad hands, text, bad eyes, bad arms, bad legs, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, blurry, grayscale, noisy, sloppy, messy, grainy, highly detailed, ultra textured, photo",
|
16 |
+
},
|
17 |
+
{
|
18 |
+
"name": "Digital Art",
|
19 |
+
"prompt": "concept art {prompt} . digital artwork, illustrative, painterly, matte painting, highly detailed",
|
20 |
+
"negative_prompt": "photo, photorealistic, realism, ugly",
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"name": "Photographic (Default)",
|
24 |
+
"prompt": "cinematic photo {prompt} . 35mm photograph, film, bokeh, professional, 4k, highly detailed",
|
25 |
+
"negative_prompt": "drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly",
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"name": "Fantasy art",
|
29 |
+
"prompt": "ethereal fantasy concept art of {prompt} . magnificent, celestial, ethereal, painterly, epic, majestic, magical, fantasy art, cover art, dreamy",
|
30 |
+
"negative_prompt": "photographic, realistic, realism, 35mm film, dslr, cropped, frame, text, deformed, glitch, noise, noisy, off-center, deformed, cross-eyed, closed eyes, bad anatomy, ugly, disfigured, sloppy, duplicate, mutated, black and white",
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"name": "Neonpunk",
|
34 |
+
"prompt": "neonpunk style {prompt} . cyberpunk, vaporwave, neon, vibes, vibrant, stunningly beautiful, crisp, detailed, sleek, ultramodern, magenta highlights, dark purple shadows, high contrast, cinematic, ultra detailed, intricate, professional",
|
35 |
+
"negative_prompt": "painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured",
|
36 |
+
},
|
37 |
+
{
|
38 |
+
"name": "Enhance",
|
39 |
+
"prompt": "breathtaking {prompt} . award-winning, professional, highly detailed",
|
40 |
+
"negative_prompt": "ugly, deformed, noisy, blurry, distorted, grainy",
|
41 |
+
},
|
42 |
+
{
|
43 |
+
"name": "Comic book",
|
44 |
+
"prompt": "comic {prompt} . graphic illustration, comic art, graphic novel art, vibrant, highly detailed",
|
45 |
+
"negative_prompt": "photograph, deformed, glitch, noisy, realistic, stock photo",
|
46 |
+
},
|
47 |
+
{
|
48 |
+
"name": "Lowpoly",
|
49 |
+
"prompt": "low-poly style {prompt} . low-poly game art, polygon mesh, jagged, blocky, wireframe edges, centered composition",
|
50 |
+
"negative_prompt": "noisy, sloppy, messy, grainy, highly detailed, ultra textured, photo",
|
51 |
+
},
|
52 |
+
{
|
53 |
+
"name": "Line art",
|
54 |
+
"prompt": "line art drawing {prompt} . professional, sleek, modern, minimalist, graphic, line art, vector graphics",
|
55 |
+
"negative_prompt": "anime, photorealistic, 35mm film, deformed, glitch, blurry, noisy, off-center, deformed, cross-eyed, closed eyes, bad anatomy, ugly, disfigured, mutated, realism, realistic, impressionism, expressionism, oil, acrylic",
|
56 |
+
}
|
57 |
+
]
|
58 |
+
|
59 |
+
styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in style_list}
|