Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
st.success("welcome") #green box
|
|
@@ -44,3 +67,4 @@ if ok == True: #user clicked
|
|
| 44 |
f"Detected {model.config.id2label[label.item()]} with confidence "
|
| 45 |
f"{round(score.item(), 3)} at location {box}"
|
| 46 |
)
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
model(input_text):
|
| 5 |
+
pipe = pipeline("object-detection", model="facebook/detr-resnet-50")
|
| 6 |
+
output=pipe("dogs1.webp")
|
| 7 |
+
return output
|
| 8 |
+
|
| 9 |
+
def main():
|
| 10 |
+
st.title("Hugging Face Model Demo")
|
| 11 |
+
|
| 12 |
+
# Create an input text box
|
| 13 |
+
input_text = st.text_input("Enter your text", "")
|
| 14 |
+
|
| 15 |
+
# Create a button to trigger model inference
|
| 16 |
+
if st.button("Analyze"):
|
| 17 |
+
# Perform inference using the loaded model
|
| 18 |
+
result = model(input_text)
|
| 19 |
+
st.write("Prediction:", result[0]['label'], "| Score:", result[0]['score'])
|
| 20 |
+
|
| 21 |
+
if __name__ == "__main__":
|
| 22 |
+
main()
|
| 23 |
+
'''
|
| 24 |
import streamlit as st
|
| 25 |
|
| 26 |
st.success("welcome") #green box
|
|
|
|
| 67 |
f"Detected {model.config.id2label[label.item()]} with confidence "
|
| 68 |
f"{round(score.item(), 3)} at location {box}"
|
| 69 |
)
|
| 70 |
+
'''
|