umeshhh commited on
Commit
0899c0c
·
verified ·
1 Parent(s): 88874d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -29
app.py CHANGED
@@ -1,29 +1,29 @@
1
- import gradio as gr
2
- from transformers import AutoProcessor, AutoModel
3
-
4
- # Step 1: Load the model and processor
5
- model_name = "facebook/VFusion3D"
6
- processor = AutoProcessor.from_pretrained(model_name)
7
- model = AutoModel.from_pretrained(model_name)
8
-
9
- # Step 2: Define the function to process inputs and get predictions
10
- def predict(input_text):
11
- # Convert input into a format the model understands
12
- inputs = processor(inputs=input_text, return_tensors="pt")
13
- # Get model predictions
14
- outputs = model(**inputs)
15
- # Return results (adjust based on the model's output format)
16
- return outputs.logits.tolist()
17
-
18
- # Step 3: Build the Gradio interface
19
- interface = gr.Interface(
20
- fn=predict,
21
- inputs="text", # Change this based on model requirements
22
- outputs="text", # Adjust output format as needed
23
- title="VFusion3D Deployment",
24
- description="A demo application."
25
- )
26
-
27
- # Step 4: Launch the app
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()