Spaces:
Running
on
Zero
Running
on
Zero
Commit
•
23d923b
1
Parent(s):
71f77fc
replace examples, support manual seed
Browse files- app.py +15 -10
- data_test/bird.jpg +0 -0
- data_test/boy.jpg +0 -0
- data_test/cat_statue.jpg +0 -0
- data_test/dragontoy.jpg +0 -0
- data_test/frog_sweater.jpg +0 -0
- data_test/gso_rabbit.jpg +0 -0
app.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
import os
|
2 |
import shlex
|
3 |
import subprocess
|
|
|
4 |
import gradio as gr
|
|
|
5 |
import spaces
|
6 |
import torch
|
7 |
from diffusers import DiffusionPipeline
|
8 |
-
from gradio_client import Client, file
|
9 |
|
10 |
subprocess.run(
|
11 |
shlex.split(
|
@@ -34,7 +35,10 @@ splat_pipeline = DiffusionPipeline.from_pretrained(
|
|
34 |
|
35 |
|
36 |
@spaces.GPU
|
37 |
-
def run(input_image):
|
|
|
|
|
|
|
38 |
input_image = input_image.astype("float32") / 255.0
|
39 |
images = image_pipeline(
|
40 |
"", input_image, guidance_scale=5, num_inference_steps=30, elevation=0
|
@@ -78,27 +82,28 @@ with block:
|
|
78 |
with gr.Row(variant="panel"):
|
79 |
with gr.Column(scale=1):
|
80 |
input_image = gr.Image(label="image", type="numpy")
|
|
|
81 |
button_gen = gr.Button("Generate")
|
82 |
|
83 |
with gr.Column(scale=1):
|
84 |
output_splat = gr.Model3D(label="3D Gaussians")
|
85 |
|
86 |
button_gen.click(
|
87 |
-
fn=run, inputs=[input_image], outputs=[output_splat]
|
88 |
)
|
89 |
|
90 |
gr.Examples(
|
91 |
examples=[
|
92 |
-
"
|
93 |
-
"
|
94 |
-
"
|
95 |
-
"
|
96 |
-
"
|
97 |
-
"
|
98 |
],
|
99 |
inputs=[input_image],
|
100 |
outputs=[output_splat],
|
101 |
-
fn=lambda x: run(input_image=x),
|
102 |
cache_examples=True,
|
103 |
label="Image-to-3D Examples",
|
104 |
)
|
|
|
1 |
import os
|
2 |
import shlex
|
3 |
import subprocess
|
4 |
+
|
5 |
import gradio as gr
|
6 |
+
import numpy as np
|
7 |
import spaces
|
8 |
import torch
|
9 |
from diffusers import DiffusionPipeline
|
|
|
10 |
|
11 |
subprocess.run(
|
12 |
shlex.split(
|
|
|
35 |
|
36 |
|
37 |
@spaces.GPU
|
38 |
+
def run(input_image, seed):
|
39 |
+
np.random.seed(seed)
|
40 |
+
torch.manual_seed(seed)
|
41 |
+
torch.cuda.manual_seed(seed)
|
42 |
input_image = input_image.astype("float32") / 255.0
|
43 |
images = image_pipeline(
|
44 |
"", input_image, guidance_scale=5, num_inference_steps=30, elevation=0
|
|
|
82 |
with gr.Row(variant="panel"):
|
83 |
with gr.Column(scale=1):
|
84 |
input_image = gr.Image(label="image", type="numpy")
|
85 |
+
seed_input = gr.Number(label="seed", value=42)
|
86 |
button_gen = gr.Button("Generate")
|
87 |
|
88 |
with gr.Column(scale=1):
|
89 |
output_splat = gr.Model3D(label="3D Gaussians")
|
90 |
|
91 |
button_gen.click(
|
92 |
+
fn=run, inputs=[input_image, seed_input], outputs=[output_splat]
|
93 |
)
|
94 |
|
95 |
gr.Examples(
|
96 |
examples=[
|
97 |
+
"https://huggingface.co/datasets/dylanebert/iso3d/resolve/main/jpg@512/a_cat_statue.jpg",
|
98 |
+
"https://huggingface.co/datasets/dylanebert/iso3d/resolve/main/jpg@512/a_baby_penguin.jpg",
|
99 |
+
"https://huggingface.co/datasets/dylanebert/iso3d/resolve/main/jpg@512/A_cartoon_house_with_red_roof.jpg",
|
100 |
+
"https://huggingface.co/datasets/dylanebert/iso3d/resolve/main/jpg@512/a_hat.jpg",
|
101 |
+
"https://huggingface.co/datasets/dylanebert/iso3d/resolve/main/jpg@512/an_antique_chest.jpg",
|
102 |
+
"https://huggingface.co/datasets/dylanebert/iso3d/resolve/main/jpg@512/metal.jpg",
|
103 |
],
|
104 |
inputs=[input_image],
|
105 |
outputs=[output_splat],
|
106 |
+
fn=lambda x: run(input_image=x, seed=42),
|
107 |
cache_examples=True,
|
108 |
label="Image-to-3D Examples",
|
109 |
)
|
data_test/bird.jpg
DELETED
Binary file (29.2 kB)
|
|
data_test/boy.jpg
DELETED
Binary file (11.8 kB)
|
|
data_test/cat_statue.jpg
DELETED
Binary file (10.8 kB)
|
|
data_test/dragontoy.jpg
DELETED
Binary file (16.6 kB)
|
|
data_test/frog_sweater.jpg
DELETED
Binary file (36.3 kB)
|
|
data_test/gso_rabbit.jpg
DELETED
Binary file (15.9 kB)
|
|