Spaces:
Runtime error
Runtime error
Commit
·
61f8f1e
0
Parent(s):
Duplicate from phenomenon1981/DreamlikeArt-PhotoReal-2.0
Browse filesCo-authored-by: Dee Jay <phenomenon1981@users.noreply.huggingface.co>
- .gitattributes +34 -0
- README.md +19 -0
- app.py +109 -0
- requirements.txt +3 -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: phenomenon1981/DreamlikeArt-PhotoReal-2.0
|
| 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,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 11 |
+
|
| 12 |
+
text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion")
|
| 13 |
+
def get_prompts(prompt_text):
|
| 14 |
+
return text_gen(prompt_text)
|
| 15 |
+
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
| 16 |
+
|
| 17 |
+
def restart_script_periodically():
|
| 18 |
+
while True:
|
| 19 |
+
time.sleep(600) # 10 minutes
|
| 20 |
+
try:
|
| 21 |
+
os.execl(sys.executable, sys.executable, *sys.argv)
|
| 22 |
+
except:
|
| 23 |
+
pass
|
| 24 |
+
|
| 25 |
+
restart_thread = Thread(target=restart_script_periodically, daemon=True)
|
| 26 |
+
restart_thread.start()
|
| 27 |
+
|
| 28 |
+
queue = Queue()
|
| 29 |
+
queue_threshold = 800
|
| 30 |
+
|
| 31 |
+
def add_random_noise(prompt, noise_level=0.07):
|
| 32 |
+
if noise_level == 0:
|
| 33 |
+
noise_level = 0.07
|
| 34 |
+
# Get the percentage of characters to add as noise
|
| 35 |
+
percentage_noise = noise_level * 5
|
| 36 |
+
# Get the number of characters to add as noise
|
| 37 |
+
num_noise_chars = int(len(prompt) * (percentage_noise/100))
|
| 38 |
+
# Get the indices of the characters to add noise to
|
| 39 |
+
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
| 40 |
+
# Add noise to the selected characters
|
| 41 |
+
prompt_list = list(prompt)
|
| 42 |
+
noise_chars = string.ascii_letters + string.punctuation + ' '
|
| 43 |
+
for index in noise_indices:
|
| 44 |
+
prompt_list[index] = random.choice(noise_chars)
|
| 45 |
+
return "".join(prompt_list)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def send_it1(inputs, noise_level, proc1=proc1):
|
| 49 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
| 50 |
+
output1 = proc1(prompt_with_noise)
|
| 51 |
+
return output1
|
| 52 |
+
|
| 53 |
+
def send_it2(inputs, noise_level, proc1=proc1):
|
| 54 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
| 55 |
+
output2 = proc1(prompt_with_noise)
|
| 56 |
+
return output2
|
| 57 |
+
|
| 58 |
+
def send_it3(inputs, noise_level, proc1=proc1):
|
| 59 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
| 60 |
+
output3 = proc1(prompt_with_noise)
|
| 61 |
+
return output3
|
| 62 |
+
|
| 63 |
+
#def send_it4(inputs, noise_level, proc1=proc1):
|
| 64 |
+
#prompt_with_noise = add_random_noise(inputs, noise_level)
|
| 65 |
+
#output4 = proc1(prompt_with_noise)
|
| 66 |
+
#return output4
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
with gr.Blocks() as myface:
|
| 72 |
+
with gr.Row():
|
| 73 |
+
|
| 74 |
+
input_text=gr.Textbox(label="Short Prompt")
|
| 75 |
+
see_prompts=gr.Button("Magic Prompt")
|
| 76 |
+
with gr.Row():
|
| 77 |
+
|
| 78 |
+
prompt=gr.Textbox(label="Enter Prompt")
|
| 79 |
+
noise_level=gr.Slider(minimum=0.0, maximum=3, step=0.1, label="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.")
|
| 80 |
+
run=gr.Button("Generate")
|
| 81 |
+
|
| 82 |
+
with gr.Row():
|
| 83 |
+
like_message = gr.Button("❤️❤️❤️ Press the Like Button if you enjoy my space! ❤️❤️❤️")
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
with gr.Row():
|
| 87 |
+
output1=gr.Image(label="Dreamlike-photoreal-2.0")
|
| 88 |
+
output2=gr.Image(label="Dreamlike-photoreal-2.0")
|
| 89 |
+
output3=gr.Image(label="Dreamlike-photoreal-2.0")
|
| 90 |
+
#output4=gr.Image(label="Dreamlike-photoreal-2.0")
|
| 91 |
+
#with gr.Row():
|
| 92 |
+
#output5=gr.Image(label="Dreamlike-photoreal-2.0")
|
| 93 |
+
#output6=gr.Image(label="Dreamlike-photoreal-2.0")
|
| 94 |
+
#with gr.Row():
|
| 95 |
+
#output7=gr.Image(label="Dreamlike-photoreal-2.0")
|
| 96 |
+
#output8=gr.Image(label="Dreamlike-photoreal-2.0")
|
| 97 |
+
|
| 98 |
+
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
|
| 99 |
+
run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
|
| 100 |
+
run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
|
| 101 |
+
run.click(send_it3, inputs=[prompt, noise_level], outputs=[output3])
|
| 102 |
+
#run.click(send_it4, inputs=[prompt, noise_level], outputs=[output4])
|
| 103 |
+
#run.click(send_it5, inputs=[prompt, noise_level], outputs=[output5])
|
| 104 |
+
#run.click(send_it6, inputs=[prompt, noise_level], outputs=[output6])
|
| 105 |
+
#run.click(send_it7, inputs=[prompt, noise_level], outputs=[output7])
|
| 106 |
+
#run.click(send_it8, inputs=[prompt, noise_level], outputs=[output8])
|
| 107 |
+
|
| 108 |
+
myface.launch(enable_queue=True, inline=True)
|
| 109 |
+
block.queue(concurrency_count=100)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
accelerate==0.12.0
|
| 2 |
+
gradio
|
| 3 |
+
xformers
|