Spaces:
Runtime error
Runtime error
yuanjie
commited on
Commit
Β·
4d15df3
1
Parent(s):
34d7a98
update
Browse files- git_init.sh +4 -0
- pages/4_π₯_Torch.py +31 -0
git_init.sh
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
|
| 3 |
+
git pull
|
| 4 |
+
git push
|
pages/4_π₯_Torch.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
# @Project : Python.
|
| 4 |
+
# @File : 4_π₯_Torch
|
| 5 |
+
# @Time : 2022/9/23 δΈε11:40
|
| 6 |
+
# @Author : yuanjie
|
| 7 |
+
# @WeChat : meutils
|
| 8 |
+
# @Software : PyCharm
|
| 9 |
+
# @Description :
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
import streamlit as st
|
| 13 |
+
from transformers import pipeline
|
| 14 |
+
from PIL import Image
|
| 15 |
+
|
| 16 |
+
pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
| 17 |
+
|
| 18 |
+
st.title("Hot Dog? Or Not?")
|
| 19 |
+
|
| 20 |
+
file_name = st.file_uploader("Upload a hot dog candidate image")
|
| 21 |
+
|
| 22 |
+
if file_name is not None:
|
| 23 |
+
col1, col2 = st.columns(2)
|
| 24 |
+
|
| 25 |
+
image = Image.open(file_name)
|
| 26 |
+
col1.image(image, use_column_width=True)
|
| 27 |
+
predictions = pipeline(image)
|
| 28 |
+
|
| 29 |
+
col2.header("Probabilities")
|
| 30 |
+
for p in predictions:
|
| 31 |
+
col2.subheader(f"{p['label']}: {round(p['score'] * 100, 1)}%")
|