MaxMilan1
commited on
Commit
·
8d4c07e
1
Parent(s):
096f517
change layout?
Browse files
app.py
CHANGED
@@ -18,16 +18,12 @@ _CITE_ = r"""
|
|
18 |
|
19 |
with gr.Blocks() as demo:
|
20 |
with gr.Tab("Text to Image Generator"):
|
21 |
-
with gr.Row():
|
22 |
with gr.Column():
|
23 |
prompt = gr.Textbox(label="Enter a discription of a shoe")
|
24 |
negative_prompt = gr.Textbox(label="Negative Prompt", value="low quality, bad quality, sketches, legs")
|
25 |
scale = gr.Slider(label="Control Image Scale", minimum=0.1, maximum=1.0, step=0.1, value=0.5)
|
26 |
-
with gr.Column():
|
27 |
control_image = gr.Image(label="Enter an image of a shoe, that you want to use as a reference", type='numpy')
|
28 |
-
# neg_prompt = gr.Textbox(label="Enter a negative prompt", value="low quality, watermark, ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo")
|
29 |
-
with gr.Row():
|
30 |
-
with gr.Column():
|
31 |
gr.Examples(
|
32 |
examples=[
|
33 |
os.path.join("examples", img_name) for img_name in sorted(os.listdir("examples"))
|
@@ -36,100 +32,88 @@ with gr.Blocks() as demo:
|
|
36 |
label="Examples",
|
37 |
cache_examples=False,
|
38 |
)
|
39 |
-
with gr.Column():
|
40 |
button_gen = gr.Button("Generate Image")
|
41 |
-
with gr.Row():
|
42 |
with gr.Column():
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
type="pil",
|
57 |
-
elem_id="content_image",
|
58 |
-
)
|
59 |
-
processed_image = gr.Image(
|
60 |
-
label="Processed Image",
|
61 |
-
image_mode="RGBA",
|
62 |
-
#width=256,
|
63 |
-
#height=256,
|
64 |
-
type="pil",
|
65 |
-
interactive=False
|
66 |
-
)
|
67 |
-
with gr.Row():
|
68 |
-
with gr.Group():
|
69 |
-
do_remove_background = gr.Checkbox(
|
70 |
-
label="Remove Background", value=True
|
71 |
)
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
step=5
|
80 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
-
with gr.
|
83 |
-
submit = gr.Button("Generate", elem_id="generate", variant="primary")
|
84 |
-
|
85 |
-
with gr.Row(variant="panel"):
|
86 |
-
gr.Examples(
|
87 |
-
examples=[
|
88 |
-
os.path.join("examples", img_name) for img_name in sorted(os.listdir("examples"))
|
89 |
-
],
|
90 |
-
inputs=[input_image],
|
91 |
-
label="Examples",
|
92 |
-
cache_examples=False,
|
93 |
-
)
|
94 |
|
95 |
-
|
96 |
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
-
with gr.
|
100 |
-
|
101 |
-
label="
|
102 |
-
|
103 |
-
width=379,
|
104 |
-
interactive=False
|
105 |
)
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
label="Output Model (OBJ Format)",
|
110 |
-
interactive=False,
|
111 |
-
)
|
112 |
-
|
113 |
-
with gr.Row():
|
114 |
-
gr.Markdown('''Try a different <b>seed value</b> if the result is unsatisfying (Default: 42).''')
|
115 |
|
116 |
-
|
117 |
|
118 |
mv_images = gr.State()
|
|
|
119 |
|
120 |
-
submit.click(fn=check_input_image, inputs=[
|
121 |
fn=preprocess,
|
122 |
-
inputs=[
|
123 |
outputs=[processed_image],
|
124 |
).success(
|
125 |
fn=generate_mvs,
|
126 |
inputs=[processed_image, sample_steps, sample_seed],
|
127 |
-
outputs=[mv_images, mv_show_images]
|
128 |
-
|
129 |
).success(
|
130 |
fn=make3d,
|
131 |
inputs=[mv_images],
|
132 |
outputs=[output_model_obj]
|
133 |
)
|
134 |
|
|
|
|
|
135 |
demo.launch()
|
|
|
18 |
|
19 |
with gr.Blocks() as demo:
|
20 |
with gr.Tab("Text to Image Generator"):
|
21 |
+
with gr.Row(variant="panel"):
|
22 |
with gr.Column():
|
23 |
prompt = gr.Textbox(label="Enter a discription of a shoe")
|
24 |
negative_prompt = gr.Textbox(label="Negative Prompt", value="low quality, bad quality, sketches, legs")
|
25 |
scale = gr.Slider(label="Control Image Scale", minimum=0.1, maximum=1.0, step=0.1, value=0.5)
|
|
|
26 |
control_image = gr.Image(label="Enter an image of a shoe, that you want to use as a reference", type='numpy')
|
|
|
|
|
|
|
27 |
gr.Examples(
|
28 |
examples=[
|
29 |
os.path.join("examples", img_name) for img_name in sorted(os.listdir("examples"))
|
|
|
32 |
label="Examples",
|
33 |
cache_examples=False,
|
34 |
)
|
|
|
35 |
button_gen = gr.Button("Generate Image")
|
|
|
36 |
with gr.Column():
|
37 |
+
gen_image = gr.Image(label="Generated Image", show_download_button=True, show_label=False)
|
38 |
+
|
39 |
+
with gr.Tab("Image to 3D Model Generator"):
|
40 |
+
with gr.Row(variant="panel"):
|
41 |
+
with gr.Column():
|
42 |
+
with gr.Row():
|
43 |
+
gen_image = gr.Image(
|
44 |
+
label="Generated Image",
|
45 |
+
image_mode="RGBA",
|
46 |
+
#width=256,
|
47 |
+
#height=256,
|
48 |
+
type="pil",
|
49 |
+
elem_id="content_image",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
)
|
51 |
+
processed_image = gr.Image(
|
52 |
+
label="Processed Image",
|
53 |
+
image_mode="RGBA",
|
54 |
+
#width=256,
|
55 |
+
#height=256,
|
56 |
+
type="pil",
|
57 |
+
interactive=False
|
|
|
58 |
)
|
59 |
+
with gr.Row():
|
60 |
+
with gr.Group():
|
61 |
+
do_remove_background = gr.Checkbox(
|
62 |
+
label="Remove Background", value=True
|
63 |
+
)
|
64 |
+
sample_seed = gr.Number(value=42, label="Seed Value", precision=0)
|
65 |
+
|
66 |
+
sample_steps = gr.Slider(
|
67 |
+
label="Sample Steps",
|
68 |
+
minimum=30,
|
69 |
+
maximum=75,
|
70 |
+
value=75,
|
71 |
+
step=5
|
72 |
+
)
|
73 |
+
|
74 |
+
with gr.Row():
|
75 |
+
submit = gr.Button("Generate", elem_id="generate", variant="primary")
|
76 |
|
77 |
+
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
+
with gr.Row():
|
80 |
|
81 |
+
with gr.Column():
|
82 |
+
mv_show_images = gr.Image(
|
83 |
+
label="Generated Multi-views",
|
84 |
+
type="pil",
|
85 |
+
width=379,
|
86 |
+
interactive=False
|
87 |
+
)
|
88 |
|
89 |
+
with gr.Row():
|
90 |
+
output_model_obj = gr.Model3D(
|
91 |
+
label="Output Model (OBJ Format)",
|
92 |
+
interactive=False,
|
|
|
|
|
93 |
)
|
94 |
|
95 |
+
with gr.Row():
|
96 |
+
gr.Markdown('''Try a different <b>seed value</b> if the result is unsatisfying (Default: 42).''')
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
+
gr.Markdown(_CITE_)
|
99 |
|
100 |
mv_images = gr.State()
|
101 |
+
gen_image = gr.State()
|
102 |
|
103 |
+
submit.click(fn=check_input_image, inputs=[gen_image]).success(
|
104 |
fn=preprocess,
|
105 |
+
inputs=[gen_image, do_remove_background],
|
106 |
outputs=[processed_image],
|
107 |
).success(
|
108 |
fn=generate_mvs,
|
109 |
inputs=[processed_image, sample_steps, sample_seed],
|
110 |
+
outputs=[mv_images, mv_show_images]
|
|
|
111 |
).success(
|
112 |
fn=make3d,
|
113 |
inputs=[mv_images],
|
114 |
outputs=[output_model_obj]
|
115 |
)
|
116 |
|
117 |
+
button_gen.click(check_prompt, inputs=[prompt]).success(generate_image, inputs=[prompt, negative_prompt, control_image, scale], outputs=[gen_image])
|
118 |
+
|
119 |
demo.launch()
|