Fabrice-TIERCELIN
commited on
Commit
•
d6e3245
1
Parent(s):
bd9036b
No image writing
Browse files
app.py
CHANGED
@@ -1,3 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from diffusers import (
|
2 |
ControlNetModel,
|
3 |
DiffusionPipeline,
|
@@ -24,7 +58,7 @@ pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
|
24 |
pipe = pipe.to(device)
|
25 |
|
26 |
def check(
|
27 |
-
|
28 |
prompt,
|
29 |
negative_prompt,
|
30 |
denoising_steps,
|
@@ -34,14 +68,14 @@ def check(
|
|
34 |
randomize_seed,
|
35 |
seed,
|
36 |
progress = gr.Progress()):
|
37 |
-
if
|
38 |
raise gr.Error("Please provide an image.")
|
39 |
|
40 |
if prompt is None or prompt == "":
|
41 |
raise gr.Error("Please provide a prompt input.")
|
42 |
|
43 |
def pix2pix(
|
44 |
-
|
45 |
prompt,
|
46 |
negative_prompt,
|
47 |
denoising_steps,
|
@@ -52,7 +86,7 @@ def pix2pix(
|
|
52 |
seed,
|
53 |
progress = gr.Progress()):
|
54 |
check(
|
55 |
-
|
56 |
prompt,
|
57 |
negative_prompt,
|
58 |
denoising_steps,
|
@@ -86,17 +120,6 @@ def pix2pix(
|
|
86 |
random.seed(seed)
|
87 |
#pipe = pipe.manual_seed(seed)
|
88 |
|
89 |
-
try:
|
90 |
-
imageio.imwrite("data.png", source_img)
|
91 |
-
except:
|
92 |
-
raise gr.Error("Can't read input image. You can try to first save your image in another format (.webp, .png, .jpeg, .bmp...).")
|
93 |
-
|
94 |
-
# Input image
|
95 |
-
try:
|
96 |
-
input_image = Image.open("data.png").convert("RGB")
|
97 |
-
except:
|
98 |
-
raise gr.Error("Can't open input image. You can try to first save your image in another format (.webp, .png, .jpeg, .bmp...).")
|
99 |
-
|
100 |
original_height, original_width, dummy_channel = np.array(input_image).shape
|
101 |
output_width = original_width
|
102 |
output_height = original_height
|
@@ -172,7 +195,7 @@ with gr.Blocks() as interface:
|
|
172 |
"""
|
173 |
)
|
174 |
with gr.Column():
|
175 |
-
|
176 |
prompt = gr.Textbox(label = 'Prompt', info = "Instruct what to change in the image", placeholder = 'Order the AI what to change in the image')
|
177 |
with gr.Accordion("Advanced options", open = False):
|
178 |
negative_prompt = gr.Textbox(label = 'Negative prompt', placeholder = 'Describe what you do NOT want to see in the image', value = 'Watermark')
|
@@ -189,7 +212,7 @@ with gr.Blocks() as interface:
|
|
189 |
information = gr.Label(label = "Information")
|
190 |
|
191 |
submit.click(check, inputs = [
|
192 |
-
|
193 |
prompt,
|
194 |
negative_prompt,
|
195 |
denoising_steps,
|
@@ -199,7 +222,7 @@ with gr.Blocks() as interface:
|
|
199 |
randomize_seed,
|
200 |
seed
|
201 |
], outputs = [], queue = False, show_progress = False).success(pix2pix, inputs = [
|
202 |
-
|
203 |
prompt,
|
204 |
negative_prompt,
|
205 |
denoising_steps,
|
@@ -215,7 +238,7 @@ with gr.Blocks() as interface:
|
|
215 |
|
216 |
gr.Examples(
|
217 |
inputs = [
|
218 |
-
|
219 |
prompt,
|
220 |
negative_prompt,
|
221 |
denoising_steps,
|
@@ -289,4 +312,4 @@ with gr.Blocks() as interface:
|
|
289 |
cache_examples = False,
|
290 |
)
|
291 |
|
292 |
-
interface.queue().launch()
|
|
|
1 |
+
|
2 |
+
Hugging Face's logo Hugging Face
|
3 |
+
|
4 |
+
Models
|
5 |
+
Datasets
|
6 |
+
Spaces
|
7 |
+
Posts
|
8 |
+
Docs
|
9 |
+
Pricing
|
10 |
+
|
11 |
+
Spaces:
|
12 |
+
Fabrice-TIERCELIN
|
13 |
+
/
|
14 |
+
Instruct-Pix2Pix-dev
|
15 |
+
private
|
16 |
+
App
|
17 |
+
Files
|
18 |
+
Community
|
19 |
+
Settings
|
20 |
+
Instruct-Pix2Pix-dev
|
21 |
+
/ app.py
|
22 |
+
Fabrice-TIERCELIN's picture
|
23 |
+
Fabrice-TIERCELIN
|
24 |
+
No image writing
|
25 |
+
4f262b3
|
26 |
+
verified
|
27 |
+
about 1 hour ago
|
28 |
+
raw
|
29 |
+
history
|
30 |
+
blame
|
31 |
+
edit
|
32 |
+
delete
|
33 |
+
No virus
|
34 |
+
10.8 kB
|
35 |
from diffusers import (
|
36 |
ControlNetModel,
|
37 |
DiffusionPipeline,
|
|
|
58 |
pipe = pipe.to(device)
|
59 |
|
60 |
def check(
|
61 |
+
input_image,
|
62 |
prompt,
|
63 |
negative_prompt,
|
64 |
denoising_steps,
|
|
|
68 |
randomize_seed,
|
69 |
seed,
|
70 |
progress = gr.Progress()):
|
71 |
+
if input_image is None:
|
72 |
raise gr.Error("Please provide an image.")
|
73 |
|
74 |
if prompt is None or prompt == "":
|
75 |
raise gr.Error("Please provide a prompt input.")
|
76 |
|
77 |
def pix2pix(
|
78 |
+
input_image,
|
79 |
prompt,
|
80 |
negative_prompt,
|
81 |
denoising_steps,
|
|
|
86 |
seed,
|
87 |
progress = gr.Progress()):
|
88 |
check(
|
89 |
+
input_image,
|
90 |
prompt,
|
91 |
negative_prompt,
|
92 |
denoising_steps,
|
|
|
120 |
random.seed(seed)
|
121 |
#pipe = pipe.manual_seed(seed)
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
original_height, original_width, dummy_channel = np.array(input_image).shape
|
124 |
output_width = original_width
|
125 |
output_height = original_height
|
|
|
195 |
"""
|
196 |
)
|
197 |
with gr.Column():
|
198 |
+
input_image = gr.Image(label = "Your image", sources = ["upload"], type = "pil")
|
199 |
prompt = gr.Textbox(label = 'Prompt', info = "Instruct what to change in the image", placeholder = 'Order the AI what to change in the image')
|
200 |
with gr.Accordion("Advanced options", open = False):
|
201 |
negative_prompt = gr.Textbox(label = 'Negative prompt', placeholder = 'Describe what you do NOT want to see in the image', value = 'Watermark')
|
|
|
212 |
information = gr.Label(label = "Information")
|
213 |
|
214 |
submit.click(check, inputs = [
|
215 |
+
input_image,
|
216 |
prompt,
|
217 |
negative_prompt,
|
218 |
denoising_steps,
|
|
|
222 |
randomize_seed,
|
223 |
seed
|
224 |
], outputs = [], queue = False, show_progress = False).success(pix2pix, inputs = [
|
225 |
+
input_image,
|
226 |
prompt,
|
227 |
negative_prompt,
|
228 |
denoising_steps,
|
|
|
238 |
|
239 |
gr.Examples(
|
240 |
inputs = [
|
241 |
+
input_image,
|
242 |
prompt,
|
243 |
negative_prompt,
|
244 |
denoising_steps,
|
|
|
312 |
cache_examples = False,
|
313 |
)
|
314 |
|
315 |
+
interface.queue().launch()
|