Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,29 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from transformers import AutoProcessor, AutoModel
|
| 3 |
-
|
| 4 |
-
#
|
| 5 |
-
model_name = "facebook/VFusion3D"
|
| 6 |
-
|
| 7 |
-
model
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
return outputs.logits.tolist()
|
| 17 |
-
|
| 18 |
-
#
|
| 19 |
-
interface = gr.Interface(
|
| 20 |
-
fn=predict,
|
| 21 |
-
inputs="text",
|
| 22 |
-
outputs="text",
|
| 23 |
-
title="VFusion3D Deployment",
|
| 24 |
-
description="A demo
|
| 25 |
-
)
|
| 26 |
-
|
| 27 |
-
#
|
| 28 |
-
if __name__ == "__main__":
|
| 29 |
-
interface.launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import AutoProcessor, AutoModel
|
| 3 |
+
|
| 4 |
+
# Model name
|
| 5 |
+
model_name = "facebook/VFusion3D"
|
| 6 |
+
|
| 7 |
+
# Load processor and model with trusted code
|
| 8 |
+
processor = AutoProcessor.from_pretrained(model_name, trust_remote_code=True)
|
| 9 |
+
model = AutoModel.from_pretrained(model_name, trust_remote_code=True)
|
| 10 |
+
|
| 11 |
+
# Define prediction function
|
| 12 |
+
def predict(input_text):
|
| 13 |
+
# Convert input into a format the model understands
|
| 14 |
+
inputs = processor(inputs=input_text, return_tensors="pt")
|
| 15 |
+
outputs = model(**inputs)
|
| 16 |
+
return outputs.logits.tolist()
|
| 17 |
+
|
| 18 |
+
# Gradio interface
|
| 19 |
+
interface = gr.Interface(
|
| 20 |
+
fn=predict,
|
| 21 |
+
inputs="text",
|
| 22 |
+
outputs="text",
|
| 23 |
+
title="VFusion3D Deployment",
|
| 24 |
+
description="A demo for facebook/VFusion3D model."
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
# Launch the app
|
| 28 |
+
if __name__ == "__main__":
|
| 29 |
+
interface.launch()
|