Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,11 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
from transformers import AutoModel, AutoTokenizer
|
| 4 |
|
| 5 |
-
# Load model and tokenizer
|
| 6 |
model_name = "Genius-Society/insecta"
|
| 7 |
-
|
| 8 |
-
model = AutoModel.from_pretrained(model_name)
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 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 |
-
|
| 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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|