Update app.py
Browse files
app.py
CHANGED
|
@@ -20,51 +20,4 @@ def main():
|
|
| 20 |
|
| 21 |
if __name__ == "__main__":
|
| 22 |
main()
|
| 23 |
-
'''
|
| 24 |
-
import streamlit as st
|
| 25 |
-
|
| 26 |
-
st.success("welcome") #green box
|
| 27 |
-
st.error("website") # red box
|
| 28 |
-
st.info("testing") # blue box
|
| 29 |
-
|
| 30 |
-
st.markdown("This is streamlit demo")
|
| 31 |
-
|
| 32 |
-
course = st.selectbox("Select the course", ['Commerce','Science','Arts'])
|
| 33 |
-
|
| 34 |
-
gender = st.radio("Select Gender ", ["Male", "Female"])
|
| 35 |
-
|
| 36 |
-
n = st.text_input("enter the number")
|
| 37 |
-
|
| 38 |
-
m = st.slider("Select value", min_value=1, max_value=100)
|
| 39 |
-
|
| 40 |
-
ok = st.button("SUBMIT")
|
| 41 |
-
if ok == True: #user clicked
|
| 42 |
-
#st.success(course+" "+gender)
|
| 43 |
|
| 44 |
-
from transformers import DetrImageProcessor, DetrForObjectDetection
|
| 45 |
-
import torch
|
| 46 |
-
from PIL import Image
|
| 47 |
-
import requests
|
| 48 |
-
|
| 49 |
-
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
| 50 |
-
image = Image.open(requests.get(url, stream=True).raw)
|
| 51 |
-
|
| 52 |
-
# you can specify the revision tag if you don't want the timm dependency
|
| 53 |
-
processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50", revision="no_timm")
|
| 54 |
-
model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50", revision="no_timm")
|
| 55 |
-
|
| 56 |
-
inputs = processor(images=image, return_tensors="pt")
|
| 57 |
-
outputs = model(**inputs)
|
| 58 |
-
|
| 59 |
-
# convert outputs (bounding boxes and class logits) to COCO API
|
| 60 |
-
# let's only keep detections with score > 0.9
|
| 61 |
-
target_sizes = torch.tensor([image.size[::-1]])
|
| 62 |
-
results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.9)[0]
|
| 63 |
-
|
| 64 |
-
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
|
| 65 |
-
box = [round(i, 2) for i in box.tolist()]
|
| 66 |
-
print(
|
| 67 |
-
f"Detected {model.config.id2label[label.item()]} with confidence "
|
| 68 |
-
f"{round(score.item(), 3)} at location {box}"
|
| 69 |
-
)
|
| 70 |
-
'''
|
|
|
|
| 20 |
|
| 21 |
if __name__ == "__main__":
|
| 22 |
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|