Commit
·
4826cf8
0
Parent(s):
Duplicate from trysem/prealnf
Browse files- .gitattributes +34 -0
- README.md +19 -0
- app.py +147 -0
- requirements.txt +4 -0
- style.css +84 -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: trysem/prealnf
|
| 11 |
+
---
|
| 12 |
+
---
|
| 13 |
+
title: DreamlikeArt-PhotoReal 2.0
|
| 14 |
+
emoji: 📈
|
| 15 |
+
colorFrom: blue
|
| 16 |
+
colorTo: yellow
|
| 17 |
+
sdk: gradio
|
| 18 |
+
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
|
| 6 |
+
import string
|
| 7 |
+
import time
|
| 8 |
+
from queue import Queue
|
| 9 |
+
from threading import Thread
|
| 10 |
+
import emoji
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
text_gen=gr.Interface.load("spaces/phenomenon1981/MagicPrompt-Stable-Diffusion")
|
| 14 |
+
def get_prompts(prompt_text):
|
| 15 |
+
return text_gen("photo, " + prompt_text)
|
| 16 |
+
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
| 17 |
+
|
| 18 |
+
def restart_script_periodically():
|
| 19 |
+
while True:
|
| 20 |
+
time.sleep(600) # 10 minutes
|
| 21 |
+
try:
|
| 22 |
+
os.execl(sys.executable, sys.executable, *sys.argv)
|
| 23 |
+
except:
|
| 24 |
+
pass
|
| 25 |
+
|
| 26 |
+
restart_thread = Thread(target=restart_script_periodically, daemon=True)
|
| 27 |
+
restart_thread.start()
|
| 28 |
+
|
| 29 |
+
queue = Queue()
|
| 30 |
+
queue_threshold = 800
|
| 31 |
+
|
| 32 |
+
def add_random_noise(prompt, noise_level=0.00):
|
| 33 |
+
if noise_level == 0:
|
| 34 |
+
noise_level = 0.00
|
| 35 |
+
# Get the percentage of characters to add as noise
|
| 36 |
+
percentage_noise = noise_level * 5
|
| 37 |
+
# Get the number of characters to add as noise
|
| 38 |
+
num_noise_chars = int(len(prompt) * (percentage_noise/100))
|
| 39 |
+
# Get the indices of the characters to add noise to
|
| 40 |
+
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
| 41 |
+
# Add noise to the selected characters
|
| 42 |
+
prompt_list = list(prompt)
|
| 43 |
+
# Add numbers, special characters, and all emojis to the list of characters used to add noise
|
| 44 |
+
noise_chars = string.ascii_letters + string.punctuation + ' ' + string.digits + emoji.emojize(":all:")
|
| 45 |
+
for index in noise_indices:
|
| 46 |
+
prompt_list[index] = random.choice(noise_chars)
|
| 47 |
+
return "".join(prompt_list)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def send_it1(inputs, noise_level, proc1=proc1):
|
| 51 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
| 52 |
+
output1 = proc1(prompt_with_noise)
|
| 53 |
+
return output1
|
| 54 |
+
|
| 55 |
+
def send_it2(inputs, noise_level, proc1=proc1):
|
| 56 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
| 57 |
+
output2 = proc1(prompt_with_noise)
|
| 58 |
+
return output2
|
| 59 |
+
|
| 60 |
+
#def send_it3(inputs, noise_level, proc1=proc1):
|
| 61 |
+
#prompt_with_noise = add_random_noise(inputs, noise_level)
|
| 62 |
+
#output3 = proc1(prompt_with_noise)
|
| 63 |
+
#return output3
|
| 64 |
+
|
| 65 |
+
#def send_it4(inputs, noise_level, proc1=proc1):
|
| 66 |
+
#prompt_with_noise = add_random_noise(inputs, noise_level)
|
| 67 |
+
#output4 = proc1(prompt_with_noise)
|
| 68 |
+
#return output4
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
| 73 |
+
gr.HTML(
|
| 74 |
+
"""
|
| 75 |
+
<div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
| 76 |
+
<div>
|
| 77 |
+
<h1 style="font-weight: 900; font-size: 3rem; margin-bottom:20px;">
|
| 78 |
+
Dreamlike Photoreal 2.0
|
| 79 |
+
</h1>
|
| 80 |
+
</div>
|
| 81 |
+
<p style="margin-bottom: 10px; font-size: 96%">
|
| 82 |
+
Noise Level: Controls how much randomness is added to the input before it is sent to the model. Higher noise level produces more diverse outputs, while lower noise level produces similar outputs,
|
| 83 |
+
<a href="https://twitter.com/DavidJohnstonxx/">created by Phenomenon1981</a>.
|
| 84 |
+
</p>
|
| 85 |
+
<p style="margin-bottom: 10px; font-size: 98%">
|
| 86 |
+
❤️ Press the Like Button if you enjoy my space! ❤️</a>
|
| 87 |
+
</p>
|
| 88 |
+
</div>
|
| 89 |
+
"""
|
| 90 |
+
)
|
| 91 |
+
with gr.Column(elem_id="col-container"):
|
| 92 |
+
with gr.Row(variant="compact"):
|
| 93 |
+
input_text = gr.Textbox(
|
| 94 |
+
label="Short Prompt",
|
| 95 |
+
show_label=False,
|
| 96 |
+
max_lines=2,
|
| 97 |
+
placeholder="Enter a basic idea and click 'Magic Prompt'",
|
| 98 |
+
).style(
|
| 99 |
+
container=False,
|
| 100 |
+
)
|
| 101 |
+
see_prompts = gr.Button("✨ Magic Prompt ✨").style(full_width=False)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
with gr.Row(variant="compact"):
|
| 105 |
+
prompt = gr.Textbox(
|
| 106 |
+
label="Enter your prompt",
|
| 107 |
+
show_label=False,
|
| 108 |
+
max_lines=2,
|
| 109 |
+
placeholder="Full Prompt",
|
| 110 |
+
).style(
|
| 111 |
+
container=False,
|
| 112 |
+
)
|
| 113 |
+
run = gr.Button("Generate Images").style(full_width=False)
|
| 114 |
+
|
| 115 |
+
with gr.Row():
|
| 116 |
+
with gr.Row():
|
| 117 |
+
noise_level = gr.Slider(minimum=0.0, maximum=3, step=0.1, label="Noise Level")
|
| 118 |
+
with gr.Row():
|
| 119 |
+
with gr.Row():
|
| 120 |
+
output1=gr.Image(label="Dreamlike-photoreal-2.0",show_label=False)
|
| 121 |
+
output2=gr.Image(label="Dreamlike-photoreal-2.0",show_label=False)
|
| 122 |
+
|
| 123 |
+
#with gr.Row():
|
| 124 |
+
#output1=gr.Image()
|
| 125 |
+
|
| 126 |
+
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
|
| 127 |
+
run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
|
| 128 |
+
run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
with gr.Row():
|
| 133 |
+
gr.HTML(
|
| 134 |
+
"""
|
| 135 |
+
<div class="footer">
|
| 136 |
+
<p> Demo for <a href="https://huggingface.co/dreamlike-art/dreamlike-photoreal-2.0">Dreamlike Photoreal 2.0</a> Stable Diffusion model
|
| 137 |
+
</p>
|
| 138 |
+
</div>
|
| 139 |
+
<div class="acknowledgments" style="font-size: 115%">
|
| 140 |
+
<p> Unleash your creative side and generate mesmerizing images with just a few clicks! Enter a spark of inspiration in the "Basic Idea" text box and click the "Magic Prompt" button to elevate it to a polished masterpiece. Make any final tweaks in the "Full Prompt" box and hit the "Generate Images" button to watch your vision come to life. Experiment with the "Noise Level" for a diverse range of outputs, from similar to wildly unique. Let the fun begin!
|
| 141 |
+
</p>
|
| 142 |
+
</div>
|
| 143 |
+
"""
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
demo.launch(enable_queue=True, inline=True)
|
| 147 |
+
block.queue(concurrency_count=100)
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
accelerate==0.12.0
|
| 2 |
+
gradio
|
| 3 |
+
xformers
|
| 4 |
+
emoji
|
style.css
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#col-container {
|
| 2 |
+
max-width: 800px;
|
| 3 |
+
margin-left: auto;
|
| 4 |
+
margin-right: auto;
|
| 5 |
+
}
|
| 6 |
+
a {
|
| 7 |
+
color: inherit;
|
| 8 |
+
text-decoration: underline;
|
| 9 |
+
}
|
| 10 |
+
.gradio-container {
|
| 11 |
+
font-family: 'IBM Plex Sans', sans-serif;
|
| 12 |
+
}
|
| 13 |
+
.gr-button {
|
| 14 |
+
color: white;
|
| 15 |
+
border-color: #9d66e5;
|
| 16 |
+
background: #9d66e5;
|
| 17 |
+
}
|
| 18 |
+
input[type='range'] {
|
| 19 |
+
accent-color: #9d66e5;
|
| 20 |
+
}
|
| 21 |
+
.dark input[type='range'] {
|
| 22 |
+
accent-color: #dfdfdf;
|
| 23 |
+
}
|
| 24 |
+
.container {
|
| 25 |
+
max-width: 800px;
|
| 26 |
+
margin: auto;
|
| 27 |
+
padding-top: 1.5rem;
|
| 28 |
+
}
|
| 29 |
+
#gallery {
|
| 30 |
+
min-height: 22rem;
|
| 31 |
+
margin-bottom: 15px;
|
| 32 |
+
margin-left: auto;
|
| 33 |
+
margin-right: auto;
|
| 34 |
+
border-bottom-right-radius: .5rem !important;
|
| 35 |
+
border-bottom-left-radius: .5rem !important;
|
| 36 |
+
}
|
| 37 |
+
#gallery>div>.h-full {
|
| 38 |
+
min-height: 20rem;
|
| 39 |
+
}
|
| 40 |
+
.details:hover {
|
| 41 |
+
text-decoration: underline;
|
| 42 |
+
}
|
| 43 |
+
.gr-button {
|
| 44 |
+
white-space: nowrap;
|
| 45 |
+
}
|
| 46 |
+
.gr-button:focus {
|
| 47 |
+
border-color: rgb(147 197 253 / var(--tw-border-opacity));
|
| 48 |
+
outline: none;
|
| 49 |
+
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
| 50 |
+
--tw-border-opacity: 1;
|
| 51 |
+
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
| 52 |
+
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
|
| 53 |
+
--tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
|
| 54 |
+
--tw-ring-opacity: .5;
|
| 55 |
+
}
|
| 56 |
+
#advanced-options {
|
| 57 |
+
margin-bottom: 20px;
|
| 58 |
+
}
|
| 59 |
+
.footer {
|
| 60 |
+
margin-bottom: 45px;
|
| 61 |
+
margin-top: 35px;
|
| 62 |
+
text-align: center;
|
| 63 |
+
border-bottom: 1px solid #e5e5e5;
|
| 64 |
+
}
|
| 65 |
+
.footer>p {
|
| 66 |
+
font-size: .8rem;
|
| 67 |
+
display: inline-block;
|
| 68 |
+
padding: 0 10px;
|
| 69 |
+
transform: translateY(10px);
|
| 70 |
+
background: white;
|
| 71 |
+
}
|
| 72 |
+
.dark .logo{ filter: invert(1); }
|
| 73 |
+
.dark .footer {
|
| 74 |
+
border-color: #303030;
|
| 75 |
+
}
|
| 76 |
+
.dark .footer>p {
|
| 77 |
+
background: #0b0f19;
|
| 78 |
+
}
|
| 79 |
+
.acknowledgments h4{
|
| 80 |
+
margin: 1.25em 0 .25em 0;
|
| 81 |
+
font-weight: bold;
|
| 82 |
+
font-size: 115%;
|
| 83 |
+
}
|
| 84 |
+
|