Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,9 +4,8 @@ from PIL import Image, ImageOps
|
|
4 |
import streamlit_authenticator as stauth
|
5 |
import yaml
|
6 |
from yaml.loader import SafeLoader
|
7 |
-
import
|
8 |
-
from
|
9 |
-
import cv2
|
10 |
|
11 |
# authentification
|
12 |
with open('./bla.yaml') as file:
|
@@ -23,21 +22,29 @@ name, authentication_status, username = authenticator.login('Login', 'main')
|
|
23 |
if authentication_status:
|
24 |
authenticator.logout('Logout', 'main')
|
25 |
page = st.sidebar.selectbox("探索或预测", ("苹果病分类","bla"))
|
|
|
26 |
|
27 |
if page == "苹果病分类":
|
28 |
st.title("使用谷歌的可教机器进行图像分类")
|
29 |
st.header("苹果病")
|
30 |
st.text("上传彩色苹果叶子图片")
|
31 |
|
|
|
|
|
|
|
|
|
32 |
uploaded_file = st.file_uploader("选择..", type=["jpg","png","jpeg"])
|
33 |
if uploaded_file is not None:
|
34 |
image = Image.open(uploaded_file).convert('RGB')
|
35 |
st.image(image, caption='上传了图片。', use_column_width=True)
|
36 |
st.write("")
|
37 |
st.write("分类...")
|
38 |
-
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
print(result)
|
41 |
# label = teachable_machine_classification(image, 'keras_model_apple.h5')
|
42 |
# if label == 0:
|
43 |
# st.write("苹果结痂")
|
|
|
4 |
import streamlit_authenticator as stauth
|
5 |
import yaml
|
6 |
from yaml.loader import SafeLoader
|
7 |
+
import torch
|
8 |
+
from diffusers import StableDiffusionPipeline
|
|
|
9 |
|
10 |
# authentification
|
11 |
with open('./bla.yaml') as file:
|
|
|
22 |
if authentication_status:
|
23 |
authenticator.logout('Logout', 'main')
|
24 |
page = st.sidebar.selectbox("探索或预测", ("苹果病分类","bla"))
|
25 |
+
|
26 |
|
27 |
if page == "苹果病分类":
|
28 |
st.title("使用谷歌的可教机器进行图像分类")
|
29 |
st.header("苹果病")
|
30 |
st.text("上传彩色苹果叶子图片")
|
31 |
|
32 |
+
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float16)
|
33 |
+
pipe = pipe.to("cuda")
|
34 |
+
|
35 |
+
|
36 |
uploaded_file = st.file_uploader("选择..", type=["jpg","png","jpeg"])
|
37 |
if uploaded_file is not None:
|
38 |
image = Image.open(uploaded_file).convert('RGB')
|
39 |
st.image(image, caption='上传了图片。', use_column_width=True)
|
40 |
st.write("")
|
41 |
st.write("分类...")
|
42 |
+
generator = torch.Generator("cuda").manual_seed(1024)
|
43 |
+
|
44 |
+
image_gen = pipe(prompt, generator=generator).images[0]
|
45 |
+
st.image(generator)
|
46 |
+
|
47 |
|
|
|
48 |
# label = teachable_machine_classification(image, 'keras_model_apple.h5')
|
49 |
# if label == 0:
|
50 |
# st.write("苹果结痂")
|