Thafx Hyphonical commited on
Commit
cecee98
·
0 Parent(s):

Duplicate from Hyphonical/Dreamlike-Grouped

Browse files

Co-authored-by: Joris Nys <Hyphonical@users.noreply.huggingface.co>

Files changed (6) hide show
  1. .gitattributes +34 -0
  2. Prompts.txt +0 -0
  3. README.md +19 -0
  4. app.py +236 -0
  5. requirements.txt +4 -0
  6. 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
Prompts.txt ADDED
The diff for this file is too large to render. See raw diff
 
README.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: DreamlikeArt-Diffusion 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: Hyphonical/Dreamlike-Grouped
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,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, sys, random, string, time, logging
2
+ from threading import Thread
3
+ from pathlib import Path
4
+ from queue import Queue
5
+ import gradio as App
6
+
7
+ logging.basicConfig(level=logging.INFO, format=f'[%(asctime)s] %(message)s', datefmt='%H:%M:%S')
8
+
9
+ logging.info('Starting Dreamlike Grouped')
10
+
11
+ logging.info('Loading MagicPrompt')
12
+ MagicPrompt=App.Interface.load('spaces/phenomenon1981/MagicPrompt-Stable-Diffusion')
13
+ def get_prompts(prompt_text):
14
+ if prompt_text:
15
+ return MagicPrompt('dreamlikeart, ' + prompt_text)
16
+ else:
17
+ return MagicPrompt('')
18
+ logging.info('loading Dreamlike Diffusion')
19
+ DreamDiffusion=App.Interface.load('models/dreamlike-art/dreamlike-diffusion-1.0') # Credits to Dreamlike
20
+ logging.info('Loading Dreamlike PhotoReal')
21
+ DreamPhotoReal = DreamDiffusion
22
+ # DreamPhotoReal=App.Interface.load('models/dreamlike-art/dreamlike-photoreal-2.0') # Credits to Dreamlike
23
+
24
+ def RestartScript():
25
+ while True:
26
+ RandomTime = random.randint(540, 600)
27
+ time.sleep(RandomTime)
28
+ os.execl(sys.executable, sys.executable, *sys.argv)
29
+
30
+ logging.info('Starting Auto-Restarter')
31
+ RestartThread = Thread(target=RestartScript, daemon=True)
32
+ RestartThread.start()
33
+
34
+ queue = Queue()
35
+ queue_threshold = 100
36
+
37
+ def AddNoise(Prompt, NoiseLevel=0.00):
38
+ if NoiseLevel == 0:
39
+ NoiseLevel = 0.00
40
+ PercentageNoise = NoiseLevel * 5
41
+ NumberNoiseCharacters = int(len(Prompt) * (PercentageNoise/100))
42
+ NoiseIndices = random.sample(range(len(Prompt)), NumberNoiseCharacters)
43
+ PromptList = list(Prompt)
44
+ NoiseCharacters = list(string.ascii_letters + string.punctuation + ' ' + string.digits)
45
+ NoiseCharacters.extend(['😍', '💩', '😂', '🤔', '😊', '🤗', '😭', '🙄', '😷', '🤯', '🤫', '🥴', '😴', '🤩', '🥳', '😔', '😩', '🤪', '😇', '🤢', '😈', '👹', '👻', '🤖', '👽', '💀', '🎃', '🎅', '🎄', '🎁', '🎂', '🎉', '🎈', '🎊', '🎮', '❤️', '💔', '💕', '💖', '💗', '🐶', '🐱', '🐭', '🐹', '🦊', '🐻', '🐨', '🐯', '🦁', '🐘', '🔥', '🌧️', '🌞', '🌈', '💥', '🌴', '🌊', '🌺', '🌻', '🌸', '🎨', '🌅', '🌌', '☁️', '⛈️', '❄️', '☀️', '🌤️', '⛅️', '🌥️', '🌦️', '🌧️', '🌩️', '🌨️', '🌫️', '☔️', '🌬️', '💨', '🌪️', '🌈'])
46
+ for Index in NoiseIndices:
47
+ PromptList[Index] = random.choice(NoiseCharacters)
48
+ return ''.join(PromptList)
49
+
50
+ def GetRandomPrompt():
51
+ with open('Prompts.txt', 'r') as Prompts:
52
+ Prompts = Prompts.readlines()
53
+ return random.choice(Prompts)
54
+
55
+ def SendIt1(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion):
56
+ logging.info('Creating Image On 8 Threads')
57
+ logging.info(f'Using Prompt: {Inputs}')
58
+ logging.info('Creating Image On Thread 1')
59
+ NoisedPrompt = AddNoise(Inputs, NoiseLevel)
60
+ while queue.qsize() >= queue_threshold:
61
+ time.sleep(2)
62
+ queue.put(NoisedPrompt)
63
+ Output1 = DreamDiffusion(NoisedPrompt)
64
+ logging.info('Done Creating Image On Thread 1')
65
+ return Output1
66
+
67
+ def SendIt2(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion):
68
+ logging.info('Creating Image On Thread 2')
69
+ NoisedPrompt = AddNoise(Inputs, NoiseLevel)
70
+ while queue.qsize() >= queue_threshold:
71
+ time.sleep(2)
72
+ queue.put(NoisedPrompt)
73
+ Output2 = DreamDiffusion(NoisedPrompt)
74
+ logging.info('Done Creating Image On Thread 2')
75
+ return Output2
76
+
77
+ def SendIt3(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion):
78
+ logging.info('Creating Image On Thread 3')
79
+ NoisedPrompt = AddNoise(Inputs, NoiseLevel)
80
+ while queue.qsize() >= queue_threshold:
81
+ time.sleep(2)
82
+ queue.put(NoisedPrompt)
83
+ Output3 = DreamDiffusion(NoisedPrompt)
84
+ logging.info('Done Creating Image On Thread 3')
85
+ return Output3
86
+
87
+ def SendIt4(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion):
88
+ logging.info('Creating Image On Thread 4')
89
+ NoisedPrompt = AddNoise(Inputs, NoiseLevel)
90
+ while queue.qsize() >= queue_threshold:
91
+ time.sleep(2)
92
+ queue.put(NoisedPrompt)
93
+ Output4 = DreamDiffusion(NoisedPrompt)
94
+ logging.info('Done Creating Image On Thread 4')
95
+ return Output4
96
+
97
+ def SendIt5(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion):
98
+ logging.info('Creating Image On Thread 5')
99
+ NoisedPrompt = AddNoise(Inputs, NoiseLevel)
100
+ while queue.qsize() >= queue_threshold:
101
+ time.sleep(2)
102
+ queue.put(NoisedPrompt)
103
+ Output5 = DreamPhotoReal(NoisedPrompt)
104
+ logging.info('Done Creating Image On Thread 5')
105
+ return Output5
106
+
107
+ def SendIt6(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion):
108
+ logging.info('Creating Image On Thread 6')
109
+ NoisedPrompt = AddNoise(Inputs, NoiseLevel)
110
+ while queue.qsize() >= queue_threshold:
111
+ time.sleep(2)
112
+ queue.put(NoisedPrompt)
113
+ Output6 = DreamPhotoReal(NoisedPrompt)
114
+ logging.info('Done Creating Image On Thread 6')
115
+ return Output6
116
+
117
+ def SendIt7(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion):
118
+ logging.info('Creating Image On Thread 7')
119
+ NoisedPrompt = AddNoise(Inputs, NoiseLevel)
120
+ while queue.qsize() >= queue_threshold:
121
+ time.sleep(2)
122
+ queue.put(NoisedPrompt)
123
+ Output7 = DreamPhotoReal(NoisedPrompt)
124
+ logging.info('Done Creating Image On Thread 7')
125
+ return Output7
126
+
127
+ def SendIt8(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion):
128
+ logging.info('Creating Image On Thread 8')
129
+ NoisedPrompt = AddNoise(Inputs, NoiseLevel)
130
+ while queue.qsize() >= queue_threshold:
131
+ time.sleep(2)
132
+ queue.put(NoisedPrompt)
133
+ Output8 = DreamPhotoReal(NoisedPrompt)
134
+ logging.info('Done Creating Image On Thread 8')
135
+ return Output8
136
+
137
+ logging.info('Loading Interface')
138
+ with App.Blocks(css='style.css') as demo:
139
+ App.HTML(
140
+ '''
141
+ <div style='text-align: center; max-width: 650px; margin: 0 auto;'>
142
+ <div>
143
+ <h1 style='font-weight: 900; font-size: 3rem; margin-bottom:20px;'>
144
+ Dreamlike Appouped
145
+ </h1>
146
+ </div>
147
+ <p style='margin-bottom: 10px; font-size: 96%'>
148
+ Dreamlike Diffusion 1.0 | Dreamlike PhotoReal 2.0
149
+ 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,
150
+ <a created by phenomenon1981</a>.
151
+ </p>
152
+ <p style='margin-bottom: 10px; font-size: 98%'>
153
+ ❤️ Press the Like Button if you enjoy my space! ❤️</a>
154
+ </p>
155
+ </div>
156
+ '''
157
+ )
158
+ with App.Column(elem_id='col-container'):
159
+ with App.Row(variant='compact'):
160
+ input_text = App.Textbox(
161
+ label='Short Prompt',
162
+ show_label=False,
163
+ max_lines=4,
164
+ placeholder='Enter a basic idea and click "Magic Prompt". Got no ideas? No problem, Simply just hit the magic button!',
165
+ ).style(
166
+ container=False,
167
+ )
168
+ output_prompt = App.Textbox(
169
+ label='Random Prompt',
170
+ show_label=False,
171
+ max_lines=4,
172
+ placeholder='Click "Random Prompt" to get a random prompt from a list!',
173
+ ).style(
174
+ container=False,
175
+ )
176
+ SeePrompts = App.Button('✨ Magic Prompt ✨').style(full_width=False)
177
+ RandomPrompt = App.Button('🔄️ Random Prompt 🔄️').style(full_width=False)
178
+
179
+
180
+ with App.Row(variant='compact'):
181
+ prompt = App.Textbox(
182
+ label='Enter your prompt',
183
+ show_label=False,
184
+ max_lines=4,
185
+ placeholder='Full Prompt',
186
+ ).style(
187
+ container=False,
188
+ )
189
+ Run = App.Button('Generate Images').style(full_width=False)
190
+
191
+ with App.Row():
192
+ with App.Row():
193
+ NoiseLevel = App.Slider(minimum=0.1, maximum=3, step=0.1, label='Noise Level', value=0.5)
194
+
195
+ with App.Row():
196
+ with App.Row():
197
+ Output1=App.Image(label='Dreamlike Diffusion 1.0',show_label=True)
198
+ Output2=App.Image(label='Dreamlike Diffusion 1.0',show_label=False)
199
+ Output3=App.Image(label='Dreamlike Diffusion 1.0',show_label=False)
200
+ Output4=App.Image(label='Dreamlike Diffusion 1.0',show_label=False)
201
+ Output5=App.Image(label='Dreamlike PhotoReal 2.0',show_label=False)
202
+ Output6=App.Image(label='Dreamlike PhotoReal 2.0',show_label=False)
203
+ Output7=App.Image(label='Dreamlike PhotoReal 2.0',show_label=False)
204
+ Output8=App.Image(label='Dreamlike PhotoReal 2.0',show_label=False)
205
+
206
+
207
+ SeePrompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
208
+ RandomPrompt.click(GetRandomPrompt, outputs=[prompt], queue=False)
209
+ Run.click(SendIt1, inputs=[prompt, NoiseLevel], outputs=[Output1])
210
+ Run.click(SendIt2, inputs=[prompt, NoiseLevel], outputs=[Output2])
211
+ Run.click(SendIt3, inputs=[prompt, NoiseLevel], outputs=[Output3])
212
+ Run.click(SendIt4, inputs=[prompt, NoiseLevel], outputs=[Output4])
213
+ Run.click(SendIt5, inputs=[prompt, NoiseLevel], outputs=[Output5])
214
+ Run.click(SendIt6, inputs=[prompt, NoiseLevel], outputs=[Output6])
215
+ Run.click(SendIt7, inputs=[prompt, NoiseLevel], outputs=[Output7])
216
+ Run.click(SendIt8, inputs=[prompt, NoiseLevel], outputs=[Output8])
217
+
218
+
219
+ with App.Row():
220
+ App.HTML(
221
+ '''
222
+ <div class='footer'>
223
+ <p> Demo for <a href='https://huggingface.co/dreamlike-art/dreamlike-diffusion-1.0'>Dreamlike Diffusion 1.0</a> Stable Diffusion model
224
+ <p> Demo for <a href='https://huggingface.co/dreamlike-art/dreamlike-photoreal-2.0'>Dreamlike PhotoReal 2.0</a> Stable Diffusion model
225
+ </p>
226
+ </div>
227
+ <div class='acknowledgments' style='font-size: 115%'>
228
+ <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!
229
+ </p>
230
+ </div>
231
+ '''
232
+ )
233
+
234
+ logging.info('Using Demo With 200 Concurrency Count')
235
+ demo.launch(enable_queue=True, inline=True, share=False)
236
+ block.queue(concurrency_count=300)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ accelerate==0.12.0
2
+ gradio
3
+ xformers
4
+ parallel-execute
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
+