Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,52 +23,34 @@ def demo_classification():
|
|
23 |
return
|
24 |
lvis_run = st.form_submit_button("Run Classification on LVIS Categories")
|
25 |
custom_run = st.form_submit_button("Run Classification on Custom Categories")
|
26 |
-
"""
|
27 |
-
if lvis_run or auto_submit("clsauto"):
|
28 |
-
pc = load_data(prog)
|
29 |
-
col2 = misc_utils.render_pc(pc)
|
30 |
-
prog.progress(0.5, "Running Classification")
|
31 |
-
pred = classification.pred_lvis_sims(model_g14, pc)
|
32 |
-
with col2:
|
33 |
-
for i, (cat, sim) in zip(range(5), pred.items()):
|
34 |
-
st.text(cat)
|
35 |
-
st.caption("Similarity %.4f" % sim)
|
36 |
-
prog.progress(1.0, "Idle")
|
37 |
-
if custom_run:
|
38 |
-
pc = load_data(prog)
|
39 |
-
col2 = misc_utils.render_pc(pc)
|
40 |
-
prog.progress(0.5, "Computing Category Embeddings")
|
41 |
-
device = clip_model.device
|
42 |
-
tn = clip_prep(text=cats, return_tensors='pt', truncation=True, max_length=76, padding=True).to(device)
|
43 |
-
feats = clip_model.get_text_features(**tn).float().cpu()
|
44 |
-
prog.progress(0.5, "Running Classification")
|
45 |
-
pred = classification.pred_custom_sims(model_g14, pc, cats, feats)
|
46 |
-
with col2:
|
47 |
-
for i, (cat, sim) in zip(range(5), pred.items()):
|
48 |
-
st.text(cat)
|
49 |
-
st.caption("Similarity %.4f" % sim)
|
50 |
-
prog.progress(1.0, "Idle")
|
51 |
-
"""
|
52 |
-
"""
|
53 |
-
if image_examples(samples_index.classification, 3, example_text="Examples (Choose one of the following 3D shapes)"):
|
54 |
-
queue_auto_submit("clsauto")
|
55 |
-
"""
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
try:
|
63 |
with tab_cls:
|
64 |
demo_classification()
|
65 |
-
"""
|
66 |
with tab_cap:
|
67 |
demo_captioning()
|
68 |
with tab_sd:
|
69 |
demo_pc2img()
|
70 |
demo_retrieval()
|
71 |
-
"""
|
72 |
except Exception:
|
73 |
import traceback
|
74 |
st.error(traceback.format_exc().replace("\n", " \n"))
|
|
|
23 |
return
|
24 |
lvis_run = st.form_submit_button("Run Classification on LVIS Categories")
|
25 |
custom_run = st.form_submit_button("Run Classification on Custom Categories")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
|
28 |
+
def demo_captioning():
|
29 |
+
with st.form("capform"):
|
30 |
+
cond_scale = st.slider('Conditioning Scale', 0.0, 4.0, 2.0, 0.1, key='capcondscl')
|
31 |
+
|
32 |
+
def demo_pc2img():
|
33 |
+
with st.form("sdform"):
|
34 |
+
prompt = st.text_input("Prompt (Optional)", key='sdtprompt')
|
35 |
+
|
36 |
+
def demo_retrieval():
|
37 |
+
with tab_pc:
|
38 |
+
k = st.slider("Shapes to Retrieve", 1, 100, 16, key='rpc')
|
39 |
+
with tab_img:
|
40 |
+
with st.form("rimgform"):
|
41 |
+
k = st.slider("Shapes to Retrieve", 1, 100, 16, key='rimage')
|
42 |
+
with tab_text:
|
43 |
+
with st.form("rtextform"):
|
44 |
+
k = st.slider("Shapes to Retrieve", 1, 100, 16, key='rtext')
|
45 |
+
text = st.text_input("Input Text", key="inputrtext")
|
46 |
try:
|
47 |
with tab_cls:
|
48 |
demo_classification()
|
|
|
49 |
with tab_cap:
|
50 |
demo_captioning()
|
51 |
with tab_sd:
|
52 |
demo_pc2img()
|
53 |
demo_retrieval()
|
|
|
54 |
except Exception:
|
55 |
import traceback
|
56 |
st.error(traceback.format_exc().replace("\n", " \n"))
|