p4vv37 commited on
Commit
dc08ad9
·
1 Parent(s): f54b709

updated requirements

Browse files
Files changed (1) hide show
  1. app.py +70 -7
app.py CHANGED
@@ -30,10 +30,73 @@ def generate_view(source_img, elevation, azimuth, camera_distance, num_inference
30
  return images[0]
31
 
32
 
33
- iface = gr.Interface(fn=generate_view, inputs=[gr.Image(type="pil", value="images/bottle.png"),
34
- gr.Number(label="elevation", value=0.),
35
- gr.Number(label="azimuth", value=45.),
36
- gr.Number(label="camera_distance", value=1.2),
37
- gr.Number(label="num_inference_steps", value=20)],
38
- outputs=gr.Image(width=256, height=256))
39
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  return images[0]
31
 
32
 
33
+ def app():
34
+ with gr.Blocks():
35
+ with gr.Row():
36
+ with gr.Column():
37
+ image = gr.Image(type="pil", value="https://huggingface.co/spaces/p4vv37/Stable-zero123/resolve/main/images/bottle.png?download=true")
38
+
39
+ elevation = gr.Number(label="elevation", value=0.)
40
+ azimuth = gr.Number(label="azimuth", value=45.)
41
+ camera_distance = gr.Number(label="camera_distance", value=1.2)
42
+ num_inference_steps = gr.Slider(
43
+ label="Inference Steps",
44
+ minimum=0,
45
+ maximum=100,
46
+ step=1,
47
+ value=20,
48
+ )
49
+
50
+ generate = gr.Button(value="Generate")
51
+
52
+ with gr.Column():
53
+ output = gr.Image(type="pil",label="Output", width=256, height=256)
54
+
55
+ generate.click(
56
+ fn=generate_view,
57
+ inputs=[
58
+ image,
59
+ elevation,
60
+ azimuth,
61
+ camera_distance,
62
+ num_inference_steps,
63
+ ],
64
+ outputs=[output],
65
+ )
66
+
67
+ gr.Examples(
68
+ examples=[
69
+ [
70
+ "images/bottle.png",
71
+ 0.,
72
+ 45.,
73
+ 1.2,
74
+ 40,
75
+ ]
76
+ ],
77
+ fn=generate_view,
78
+ inputs=[
79
+ image,
80
+ elevation,
81
+ azimuth,
82
+ camera_distance,
83
+ num_inference_steps,
84
+ ],
85
+ outputs=[output],
86
+ cache_examples=True,
87
+ )
88
+
89
+
90
+ gradio_app = gr.Blocks()
91
+ with gradio_app:
92
+ gr.HTML(
93
+ """
94
+ <h1 style='text-align: center'>
95
+ Demo of new view generation with [Stable-Zero123] (https://huggingface.co/stabilityai/stable-zero123) implemented in [stable-zero123-diffusers](https://huggingface.co/ashawkey/stable-zero123-diffusers)
96
+ </h1>
97
+ """)
98
+ with gr.Row():
99
+ with gr.Column():
100
+ app()
101
+
102
+ gradio_app.launch(debug=True)