Yntec phenomenon1981 commited on
Commit
684212e
0 Parent(s):

Duplicate from phenomenon1981/Dreamlikeart-Anime-1.0

Browse files

Co-authored-by: Dee Jay <[email protected]>

Files changed (5) hide show
  1. .gitattributes +34 -0
  2. README.md +19 -0
  3. app.py +154 -0
  4. requirements.txt +4 -0
  5. 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-Anime 1.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-Anime-1.0
11
+ ---
12
+ ---
13
+ title: DreamlikeArt-Diffusion .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,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ text_gen=gr.Interface.load("spaces/phenomenon1981/MagicPrompt-Stable-Diffusion")
13
+ def get_prompts(prompt_text):
14
+ if prompt_text:
15
+ return text_gen("photo anime, masterpiece, high quality, absurdres, " + prompt_text)
16
+ else:
17
+ return text_gen("")
18
+ proc1=gr.Interface.load("models/dreamlike-art/dreamlike-anime-1.0")
19
+
20
+ def restart_script_periodically():
21
+ while True:
22
+ random_time = random.randint(540, 600)
23
+ time.sleep(random_time)
24
+ os.execl(sys.executable, sys.executable, *sys.argv)
25
+
26
+
27
+ restart_thread = Thread(target=restart_script_periodically, daemon=True)
28
+ restart_thread.start()
29
+
30
+
31
+ queue = Queue()
32
+ queue_threshold = 100
33
+
34
+ def add_random_noise(prompt, noise_level=0.00):
35
+ if noise_level == 0:
36
+ noise_level = 0.00
37
+ percentage_noise = noise_level * 5
38
+ num_noise_chars = int(len(prompt) * (percentage_noise/100))
39
+ noise_indices = random.sample(range(len(prompt)), num_noise_chars)
40
+ prompt_list = list(prompt)
41
+ noise_chars = list(string.ascii_letters + string.punctuation + ' ' + string.digits)
42
+ noise_chars.extend(['😍', '💩', '😂', '🤔', '😊', '🤗', '😭', '🙄', '😷', '🤯', '🤫', '🥴', '😴', '🤩', '🥳', '😔', '😩', '🤪', '😇', '🤢', '😈', '👹', '👻', '🤖', '👽', '💀', '🎃', '🎅', '🎄', '🎁', '🎂', '🎉', '🎈', '🎊', '🎮', '❤️', '💔', '💕', '💖', '💗', '🐶', '🐱', '🐭', '🐹', '🦊', '🐻', '🐨', '🐯', '🦁', '🐘', '🔥', '🌧️', '🌞', '🌈', '💥', '🌴', '🌊', '🌺', '🌻', '🌸', '🎨', '🌅', '🌌', '☁️', '⛈️', '❄️', '☀️', '🌤️', '⛅️', '🌥️', '🌦️', '🌧️', '🌩️', '🌨️', '🌫️', '☔️', '🌬️', '💨', '🌪️', '🌈'])
43
+ for index in noise_indices:
44
+ prompt_list[index] = random.choice(noise_chars)
45
+ return "".join(prompt_list)
46
+
47
+
48
+
49
+ def send_it1(inputs, noise_level, proc1=proc1):
50
+ prompt_with_noise = add_random_noise(inputs, noise_level)
51
+ while queue.qsize() >= queue_threshold:
52
+ time.sleep(2)
53
+ queue.put(prompt_with_noise)
54
+ output1 = proc1(prompt_with_noise)
55
+ return output1
56
+
57
+ def send_it2(inputs, noise_level, proc1=proc1):
58
+ prompt_with_noise = add_random_noise(inputs, noise_level)
59
+ while queue.qsize() >= queue_threshold:
60
+ time.sleep(2)
61
+ queue.put(prompt_with_noise)
62
+ output2 = proc1(prompt_with_noise)
63
+ return output2
64
+
65
+ #def send_it3(inputs, noise_level, proc1=proc1):
66
+ #prompt_with_noise = add_random_noise(inputs, noise_level)
67
+ #while queue.qsize() >= queue_threshold:
68
+ #time.sleep(2)
69
+ #queue.put(prompt_with_noise)
70
+ #output3 = proc1(prompt_with_noise)
71
+ #return output3
72
+
73
+ #def send_it4(inputs, noise_level, proc1=proc1):
74
+ #prompt_with_noise = add_random_noise(inputs, noise_level)
75
+ #while queue.qsize() >= queue_threshold:
76
+ #time.sleep(2)
77
+ #queue.put(prompt_with_noise)
78
+ #output4 = proc1(prompt_with_noise)
79
+ #return output4
80
+
81
+
82
+ with gr.Blocks(css='style.css') as demo:
83
+ gr.HTML(
84
+ """
85
+ <div style="text-align: center; max-width: 650px; margin: 0 auto;">
86
+ <div>
87
+ <h1 style="font-weight: 900; font-size: 3rem; margin-bottom:20px;">
88
+ Dreamlike Anime 1.0
89
+ </h1>
90
+ </div>
91
+ <p style="margin-bottom: 10px; font-size: 96%">
92
+ 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,
93
+ <a href="https://twitter.com/DavidJohnstonxx/">created by Phenomenon1981</a>.
94
+ </p>
95
+ <p style="margin-bottom: 10px; font-size: 98%">
96
+ ❤️ Press the Like Button if you enjoy my space! ❤️</a>
97
+ </p>
98
+ </div>
99
+ """
100
+ )
101
+ with gr.Column(elem_id="col-container"):
102
+ with gr.Row(variant="compact"):
103
+ input_text = gr.Textbox(
104
+ label="Short Prompt",
105
+ show_label=False,
106
+ max_lines=2,
107
+ placeholder="Enter a basic idea and click 'Magic Prompt'. Got no ideas? No problem, Simply just hit the magic button!",
108
+ ).style(
109
+ container=False,
110
+ )
111
+ see_prompts = gr.Button("✨ Magic Prompt ✨").style(full_width=False)
112
+
113
+
114
+ with gr.Row(variant="compact"):
115
+ prompt = gr.Textbox(
116
+ label="Enter your prompt",
117
+ show_label=False,
118
+ max_lines=2,
119
+ placeholder="Full Prompt",
120
+ ).style(
121
+ container=False,
122
+ )
123
+ run = gr.Button("Generate Images").style(full_width=False)
124
+
125
+ with gr.Row():
126
+ with gr.Row():
127
+ noise_level = gr.Slider(minimum=0.0, maximum=3, step=0.1, label="Noise Level")
128
+ with gr.Row():
129
+ with gr.Row():
130
+ output1=gr.Image(label="Dreamlike Anime 1.0",show_label=False)
131
+ output2=gr.Image(label="Dreamlike Anime 1.0",show_label=False)
132
+
133
+
134
+ see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
135
+ run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
136
+ run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
137
+
138
+
139
+ with gr.Row():
140
+ gr.HTML(
141
+ """
142
+ <div class="footer">
143
+ <p> Demo for <a href="https://huggingface.co/dreamlike-art/dreamlike-anime-1.0">Dreamlike Anime 1.0</a> Stable Diffusion model
144
+ </p>
145
+ </div>
146
+ <div class="acknowledgments" style="font-size: 115%">
147
+ <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!
148
+ </p>
149
+ </div>
150
+ """
151
+ )
152
+
153
+ demo.launch(enable_queue=True, inline=True)
154
+ 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
+