yuanjie commited on
Commit
4d15df3
β€’
1 Parent(s): 34d7a98
Files changed (2) hide show
  1. git_init.sh +4 -0
  2. 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)}%")