Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,31 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
pipe=pipeline("sentiment-analysis")
|
5 |
-
text=st.text_area("enter the text:")
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
if text:
|
10 |
-
out=pipe(text)
|
11 |
-
st.json(out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
#pipe=pipeline("sentiment-analysis")
|
5 |
+
#text=st.text_area("enter the text:")
|
6 |
+
##x = st.slider('Select a value')
|
7 |
+
##st.write(x, 'squared is', x * x)
|
8 |
+
|
9 |
+
#if text:
|
10 |
+
#out=pipe(text)
|
11 |
+
#st.json(out)
|
12 |
+
|
13 |
+
from transformers import DetrFeatureExtractor, DetrForObjectDetection
|
14 |
+
from PIL import Image
|
15 |
+
import requests
|
16 |
+
|
17 |
+
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
18 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
19 |
+
|
20 |
+
feature_extractor = DetrFeatureExtractor.from_pretrained('facebook/detr-resnet-50')
|
21 |
+
model = DetrForObjectDetection.from_pretrained('facebook/detr-resnet-50')
|
22 |
+
|
23 |
+
inputs = feature_extractor(images=image, return_tensors="pt")
|
24 |
+
outputs = model(**inputs)
|
25 |
+
|
26 |
+
# model predicts bounding boxes and corresponding COCO classes
|
27 |
+
logits = outputs.logits
|
28 |
+
bboxes = outputs.pred_boxes
|
29 |
+
|
30 |
+
if bboxes:
|
31 |
+
st.json(bboxes)
|