Spaces:
Running
Running
Commit
•
c21c77f
0
Parent(s):
Duplicate from jin-nin/artist
Browse files- .gitattributes +34 -0
- README.md +19 -0
- app.py +117 -0
- requirements.txt +4 -0
- style.css +117 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: DreamlikeArt-PhotoReal 2.0
|
3 |
+
emoji: 📈
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: yellow
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.16.1
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: jin-nin/artist
|
11 |
+
---
|
12 |
+
---
|
13 |
+
title: DreamlikeArt-PhotoReal 2.0
|
14 |
+
emoji: 📈
|
15 |
+
colorFrom: blue
|
16 |
+
colorTo: yellow
|
17 |
+
sdk: gradio
|
18 |
+
sdk_version: 3.16.1
|
19 |
+
app_file: app.py
|
app.py
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
import sys
|
4 |
+
from pathlib import Path
|
5 |
+
import random
|
6 |
+
import string
|
7 |
+
import time
|
8 |
+
from queue import Queue
|
9 |
+
from threading import Thread
|
10 |
+
import emoji
|
11 |
+
|
12 |
+
def pipe(val):
|
13 |
+
return val
|
14 |
+
|
15 |
+
ru2en = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-ru-en")
|
16 |
+
|
17 |
+
text_gen=gr.Interface.load("spaces/phenomenon1981/MagicPrompt-Stable-Diffusion")
|
18 |
+
def get_prompts(prompt_text):
|
19 |
+
return text_gen("photo, " + prompt_text + ", high details, harmony, ideal proportions")
|
20 |
+
|
21 |
+
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
22 |
+
|
23 |
+
def restart_script_periodically():
|
24 |
+
while True:
|
25 |
+
time.sleep(600) # 10 minutes
|
26 |
+
try:
|
27 |
+
os.execl(sys.executable, sys.executable, *sys.argv)
|
28 |
+
except:
|
29 |
+
pass
|
30 |
+
|
31 |
+
restart_thread = Thread(target=restart_script_periodically, daemon=True)
|
32 |
+
restart_thread.start()
|
33 |
+
|
34 |
+
queue = Queue()
|
35 |
+
queue_threshold = 800
|
36 |
+
|
37 |
+
def add_random_noise(prompt, noise_level=0.00):
|
38 |
+
if noise_level == 0:
|
39 |
+
noise_level = 0.00
|
40 |
+
# Get the percentage of characters to add as noise
|
41 |
+
percentage_noise = noise_level * 5
|
42 |
+
# Get the number of characters to add as noise
|
43 |
+
num_noise_chars = int(len(prompt) * (percentage_noise/100))
|
44 |
+
# Get the indices of the characters to add noise to
|
45 |
+
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
46 |
+
# Add noise to the selected characters
|
47 |
+
prompt_list = list(prompt)
|
48 |
+
# Add numbers, special characters, and all emojis to the list of characters used to add noise
|
49 |
+
noise_chars = string.ascii_letters + string.punctuation + ' ' + string.digits + emoji.emojize(":all:")
|
50 |
+
for index in noise_indices:
|
51 |
+
prompt_list[index] = random.choice(noise_chars)
|
52 |
+
return "".join(prompt_list)
|
53 |
+
|
54 |
+
|
55 |
+
def send_it(inputs, noise_level, proc1=proc1):
|
56 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
57 |
+
output = proc1(prompt_with_noise)
|
58 |
+
return output
|
59 |
+
|
60 |
+
with gr.Blocks(analytics_enabled=False, css='style.css') as demo:
|
61 |
+
with gr.Column(elem_id="col-container"):
|
62 |
+
|
63 |
+
with gr.Row(elem_id="shorts"):
|
64 |
+
input_text_ru = gr.Textbox(
|
65 |
+
label="Short Ru",
|
66 |
+
placeholder="девушка",
|
67 |
+
)
|
68 |
+
Translate = gr.Button("Ru ▶ En", elem_id="translate").style(full_width=False)
|
69 |
+
input_text = gr.Textbox(
|
70 |
+
label="Short En",
|
71 |
+
placeholder="girl",
|
72 |
+
)
|
73 |
+
|
74 |
+
with gr.Row(elem_id="longs"):
|
75 |
+
with gr.Column(scale=1000):
|
76 |
+
prompt = gr.Textbox(
|
77 |
+
label="Prompt",
|
78 |
+
placeholder="proto, girl, high details",
|
79 |
+
)
|
80 |
+
with gr.Column(scale=1, elem_id="longs-fillers"):
|
81 |
+
Literally = gr.Button("◀ Literally")
|
82 |
+
Explain = gr.Button("◀ Explain")
|
83 |
+
|
84 |
+
with gr.Row(elem_id="params"):
|
85 |
+
with gr.Column():
|
86 |
+
noise_level = gr.Slider(minimum=0.0, value=1.0, maximum=3, step=0.1, label="Noise Level")
|
87 |
+
|
88 |
+
with gr.Row(elem_id="paints"):
|
89 |
+
with gr.Column():
|
90 |
+
run1 = gr.Button("🔻 Paint")
|
91 |
+
output1=gr.Image()
|
92 |
+
with gr.Column():
|
93 |
+
run2 = gr.Button("🔻 Paint")
|
94 |
+
output2=gr.Image()
|
95 |
+
with gr.Column():
|
96 |
+
run3 = gr.Button("🔻 Paint")
|
97 |
+
output3=gr.Image()
|
98 |
+
# with gr.Column():
|
99 |
+
# run4 = gr.Button("🔻 Paint")
|
100 |
+
# output4=gr.Image()
|
101 |
+
|
102 |
+
gr.Markdown("Honor **Artists**: Yayoi Kusama, Pablo Picasso, Leonardo da Vinci, Banksy, Rembrandt, Frida Kahlo, Vincent van Gogh, Henri Matisse, Salvador Dali, Claude Monet, Andy Warhol, Georgia O'Keeffe, Jackson Pollock, Marcel Duchamp, Edward Hopper, Willem de Kooning, Mark Rothko, David Hockney")
|
103 |
+
gr.Markdown("Popuar **Styles**: Anime, Abstract, Minimalist, Cyberpunk, Steampunk, Organic, Geometric, Sci-Fi, Futuristic, Vaporwave, Gothic")
|
104 |
+
gr.Markdown("Known **Moods**: joyful, light-hearted, exciting, calming, soothing, playful, fun, bright, colourful, dynamic, energetic, passionate, romantic, vibrant, vivid")
|
105 |
+
gr.Markdown("Typical **Techniques**: oil on canvas, chinese painting, graffiti, watercolour, graphite, cinematic, film noir, fluorescent, moody lighting, silhouette, ultraviolet, x-ray, olaroid, double exposure, fisheye lens, bokeh")
|
106 |
+
|
107 |
+
Literally.click(pipe, inputs=[input_text], outputs=[prompt], queue=False)
|
108 |
+
Translate.click(ru2en, inputs=[input_text_ru], outputs=[input_text], queue=False, api_name="ru2en")
|
109 |
+
Explain.click(text_gen, inputs=[input_text], outputs=[prompt], queue=False, api_name="explain")
|
110 |
+
|
111 |
+
run1.click(send_it, inputs=[prompt, noise_level], outputs=[output1], api_name="paint/0")
|
112 |
+
run2.click(send_it, inputs=[prompt, noise_level], outputs=[output2], api_name="paint/1")
|
113 |
+
run3.click(send_it, inputs=[prompt, noise_level], outputs=[output3], api_name="paint/2")
|
114 |
+
# run4.click(send_it, inputs=[prompt, noise_level], outputs=[output4])
|
115 |
+
|
116 |
+
demo.launch(enable_queue=True, inline=True, show_api=False)
|
117 |
+
block.queue(concurrency_count=2)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
accelerate==0.12.0
|
2 |
+
gradio
|
3 |
+
xformers
|
4 |
+
emoji
|
style.css
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.gr-box, .gr-form {
|
2 |
+
background: none !important;
|
3 |
+
border: none !important;
|
4 |
+
}
|
5 |
+
.gr-input {
|
6 |
+
background: #131d26 !important;
|
7 |
+
box-shadow: inset 0 0 0 1px #293139 !important;
|
8 |
+
border-radius: 2px !important;
|
9 |
+
padding: .5rem .75rem !important;
|
10 |
+
font-size: 1rem !important;
|
11 |
+
line-height: 1.5rem !important;
|
12 |
+
}
|
13 |
+
.gr-input:hover {
|
14 |
+
box-shadow: inset 0 0 0 2px #293139 !important;
|
15 |
+
}
|
16 |
+
input::-webkit-slider-runnable-track {
|
17 |
+
background: #131d26 !important;
|
18 |
+
box-shadow: inset 0 0 0 1px #293139 !important;
|
19 |
+
border-radius: 2px !important;
|
20 |
+
}
|
21 |
+
|
22 |
+
body {
|
23 |
+
overflow: overlay;
|
24 |
+
}
|
25 |
+
::-webkit-scrollbar {
|
26 |
+
width: .25rem;
|
27 |
+
height: .25rem;
|
28 |
+
}
|
29 |
+
:hover::-webkit-scrollbar {
|
30 |
+
width: .5rem;
|
31 |
+
height: .5rem;
|
32 |
+
}
|
33 |
+
::-webkit-scrollbar-corner {
|
34 |
+
background-color: #293139;
|
35 |
+
}
|
36 |
+
::-webkit-scrollbar-track {
|
37 |
+
background-color: transparent;
|
38 |
+
}
|
39 |
+
::-webkit-scrollbar-thumb {
|
40 |
+
background-color: #293139;
|
41 |
+
border-radius: 2px;
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
label > .z-40 {
|
46 |
+
font-size: 1rem !important;
|
47 |
+
padding: 0 0.75rem !important;
|
48 |
+
}
|
49 |
+
|
50 |
+
.gr-button:active, .gr-button:active, {
|
51 |
+
border: none !important;
|
52 |
+
outline: none !important;
|
53 |
+
}
|
54 |
+
.gr-button:hover, .gr-button:focus, .gr-button:active {
|
55 |
+
background: rgba( 255, 255, 255, .1 ) !important;
|
56 |
+
border: none !important;
|
57 |
+
}
|
58 |
+
.gr-button {
|
59 |
+
color: #6699cc !important;
|
60 |
+
border: none !important;
|
61 |
+
font-weight: normal !important;
|
62 |
+
background: transparent !important;
|
63 |
+
border-radius: 2px !important;
|
64 |
+
padding: .5rem .75rem !important;
|
65 |
+
min-width: auto !important;
|
66 |
+
white-space: nowrap !important;
|
67 |
+
align-self: center !important;
|
68 |
+
}
|
69 |
+
|
70 |
+
#translate {
|
71 |
+
margin-top: 2.5rem !important;
|
72 |
+
align-self: flex-start !important;
|
73 |
+
}
|
74 |
+
|
75 |
+
.output-markdown {
|
76 |
+
margin: .5rem .75rem !important;
|
77 |
+
}
|
78 |
+
|
79 |
+
body, .gradio-container {
|
80 |
+
font: 1rem/1.5rem 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
|
81 |
+
}
|
82 |
+
|
83 |
+
.container {
|
84 |
+
max-width: none !important;
|
85 |
+
background: #15202a !important;
|
86 |
+
padding: .75rem !important;
|
87 |
+
}
|
88 |
+
|
89 |
+
footer {
|
90 |
+
display: none !important;
|
91 |
+
}
|
92 |
+
|
93 |
+
#longs-fillers {
|
94 |
+
min-width: auto !important;
|
95 |
+
}
|
96 |
+
#longs-fillers .gr-button {
|
97 |
+
justify-content: flex-start !important;
|
98 |
+
}
|
99 |
+
|
100 |
+
.gap-4 {
|
101 |
+
gap: 0 !important;
|
102 |
+
}
|
103 |
+
|
104 |
+
#paints > * {
|
105 |
+
margin: .75rem !important;
|
106 |
+
}
|
107 |
+
|
108 |
+
#paints > * > .border {
|
109 |
+
box-shadow: 0 0 0 1px rgba( 255, 255, 255, .1 ) !important;
|
110 |
+
background: rgba(0,0,0,.1) !important;
|
111 |
+
border-radius: 2px !important;
|
112 |
+
overflow: hidden !important;
|
113 |
+
}
|
114 |
+
|
115 |
+
#paints > * > .border > .absolute {
|
116 |
+
display: none !important;
|
117 |
+
}
|