Spaces:
Runtime error
Runtime error
ff
Browse files- gradio_seg2image.py +19 -0
gradio_seg2image.py
CHANGED
@@ -1,7 +1,22 @@
|
|
1 |
# This file is adapted from https://github.com/lllyasviel/ControlNet/blob/f4748e3630d8141d7765e2bd9b1e348f47847707/gradio_seg2image.py
|
2 |
# The original license file is LICENSE.ControlNet in this repo.
|
3 |
import gradio as gr
|
|
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
def create_demo(process, max_images=12):
|
7 |
with gr.Blocks() as demo:
|
@@ -59,6 +74,8 @@ def create_demo(process, max_images=12):
|
|
59 |
show_label=False,
|
60 |
elem_id='gallery').style(
|
61 |
grid=2, height='auto')
|
|
|
|
|
62 |
ips = [
|
63 |
input_image, prompt, a_prompt, n_prompt, num_samples,
|
64 |
image_resolution, detect_resolution, ddim_steps, scale, seed, eta
|
@@ -67,4 +84,6 @@ def create_demo(process, max_images=12):
|
|
67 |
inputs=ips,
|
68 |
outputs=[result_gallery],
|
69 |
api_name='seg')
|
|
|
|
|
70 |
return demo
|
|
|
1 |
# This file is adapted from https://github.com/lllyasviel/ControlNet/blob/f4748e3630d8141d7765e2bd9b1e348f47847707/gradio_seg2image.py
|
2 |
# The original license file is LICENSE.ControlNet in this repo.
|
3 |
import gradio as gr
|
4 |
+
from PIL import Image
|
5 |
|
6 |
+
def dummyfun(result_gallery):
|
7 |
+
print(f"type of gallery is ^^ - {type(result_gallery)}")
|
8 |
+
print(f"length of gallery is ^^ - {len(result_gallery)}")
|
9 |
+
print(f"first elem of gallery is ^^ - {result_gallery[0]}")
|
10 |
+
print(f"first elem of gallery is ^^ - {result_gallery[1]}")
|
11 |
+
# Load the image
|
12 |
+
image = result_gallery[1] £Image.open("example.jpg")
|
13 |
+
|
14 |
+
# Get the filename
|
15 |
+
filename = image.filename
|
16 |
+
|
17 |
+
# Print the filename
|
18 |
+
print(f"filename is ^^ - {filename}")
|
19 |
+
return filename
|
20 |
|
21 |
def create_demo(process, max_images=12):
|
22 |
with gr.Blocks() as demo:
|
|
|
74 |
show_label=False,
|
75 |
elem_id='gallery').style(
|
76 |
grid=2, height='auto')
|
77 |
+
b1 = gr.Button('Get filenames')
|
78 |
+
filename = gr.Textbox(label="image file names")
|
79 |
ips = [
|
80 |
input_image, prompt, a_prompt, n_prompt, num_samples,
|
81 |
image_resolution, detect_resolution, ddim_steps, scale, seed, eta
|
|
|
84 |
inputs=ips,
|
85 |
outputs=[result_gallery],
|
86 |
api_name='seg')
|
87 |
+
b1.click(dummyfun, [result_gallery], [filename])
|
88 |
+
|
89 |
return demo
|