Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
import requests
|
5 |
+
from PIL import Image
|
6 |
+
|
7 |
+
obj_model = pipeline("object-detection", model="facebook/detr-resnet-50")
|
8 |
+
|
9 |
+
def get_img_from_url(url):
|
10 |
+
return Image.open(requests.get(url, stream=True).raw)
|
11 |
+
|
12 |
+
def main():
|
13 |
+
st.title("Object Detection")
|
14 |
+
|
15 |
+
with st.form("text_field"):
|
16 |
+
url = st.text_input("URL to some image")
|
17 |
+
img = get_img_from_url(url)
|
18 |
+
# clicked==True only when the button is clicked
|
19 |
+
clicked = st.form_submit_button("Submit")
|
20 |
+
if clicked:
|
21 |
+
results = obj_model(img)
|
22 |
+
st.json(results)
|