Spaces:
Running
Running
SerdarHelli
commited on
Commit
•
47dddc9
1
Parent(s):
a589fb1
Update app.py
Browse files
app.py
CHANGED
@@ -45,7 +45,6 @@ def seed_all(seed):
|
|
45 |
|
46 |
|
47 |
def change_model(ckpt_path):
|
48 |
-
global model
|
49 |
if device=="cuda":
|
50 |
model = StyleGAN2_3D.load_from_checkpoint(cars).cuda(0)
|
51 |
else:
|
@@ -78,10 +77,9 @@ def predict(seed,trunc_psi):
|
|
78 |
|
79 |
return x,y,z,i,j,k
|
80 |
|
81 |
-
def generate(seed,
|
82 |
|
83 |
-
|
84 |
-
change_model(models[model])
|
85 |
x,y,z,i,j,k=predict(seed,trunc_psi)
|
86 |
|
87 |
|
@@ -123,12 +121,12 @@ with gr.Blocks() as demo:
|
|
123 |
gr.Markdown(markdown)
|
124 |
with gr.Row():
|
125 |
seed = gr.Slider( minimum=0, maximum=2**16,label='Seed')
|
126 |
-
|
127 |
trunc_psi = gr.Slider( minimum=0, maximum=2,label='Truncate PSI')
|
128 |
|
129 |
btn = gr.Button(value="Generate")
|
130 |
mesh = gr.Plot()
|
131 |
-
demo.load(generate, [seed,
|
132 |
-
btn.click(generate, [seed,
|
133 |
|
134 |
demo.launch(debug=True)
|
|
|
45 |
|
46 |
|
47 |
def change_model(ckpt_path):
|
|
|
48 |
if device=="cuda":
|
49 |
model = StyleGAN2_3D.load_from_checkpoint(cars).cuda(0)
|
50 |
else:
|
|
|
77 |
|
78 |
return x,y,z,i,j,k
|
79 |
|
80 |
+
def generate(seed,model_name,trunc_psi):
|
81 |
|
82 |
+
change_model(models[model_name])
|
|
|
83 |
x,y,z,i,j,k=predict(seed,trunc_psi)
|
84 |
|
85 |
|
|
|
121 |
gr.Markdown(markdown)
|
122 |
with gr.Row():
|
123 |
seed = gr.Slider( minimum=0, maximum=2**16,label='Seed')
|
124 |
+
model_name=gr.Dropdown(choices=["Car","Airplane","Chair","Rifle","Table"],label="Choose Model Type")
|
125 |
trunc_psi = gr.Slider( minimum=0, maximum=2,label='Truncate PSI')
|
126 |
|
127 |
btn = gr.Button(value="Generate")
|
128 |
mesh = gr.Plot()
|
129 |
+
demo.load(generate, [seed,model_name,trunc_psi], mesh)
|
130 |
+
btn.click(generate, [seed,model_name,trunc_psi], mesh)
|
131 |
|
132 |
demo.launch(debug=True)
|