tbelvin5969 commited on
Commit
932866d
·
verified ·
1 Parent(s): 02c8082

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -23
app.py CHANGED
@@ -1,28 +1,11 @@
1
  import gradio as gr
2
- import torch
3
- from transformers import AutoModel, AutoTokenizer
4
 
5
- # Load model and tokenizer
6
  model_name = "Genius-Society/insecta"
7
- tokenizer = AutoTokenizer.from_pretrained(model_name)
8
- model = AutoModel.from_pretrained(model_name)
9
 
10
- # Define inference function
11
- def generate_response(prompt):
12
- inputs = tokenizer(prompt, return_tensors="pt") # Tokenize input text
13
- with torch.no_grad(): # Disable gradients for inference
14
- output = model(**inputs)
15
 
16
- return str(output) # Convert output to string for display
17
-
18
- # Create Gradio interface
19
- iface = gr.Interface(
20
- fn=generate_response,
21
- inputs="text",
22
- outputs="text",
23
- title="Insecta AI Model",
24
- description="Generate responses using Genius-Society/Insecta hosted on Hugging Face Spaces."
25
- )
26
-
27
- if __name__ == "__main__":
28
- iface.launch()
 
1
  import gradio as gr
2
+ from transformers import pipeline
 
3
 
 
4
  model_name = "Genius-Society/insecta"
5
+ detection_pipeline = pipeline("object-detection", model=model_name)
 
6
 
7
+ def detect_objects(image):
8
+ return detection_pipeline(image)
 
 
 
9
 
10
+ iface = gr.Interface(fn=detect_objects, inputs="image", outputs="json")
11
+ iface.launch()