Tapanat commited on
Commit
4d9de5b
·
1 Parent(s): d90361e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -20
app.py CHANGED
@@ -1,26 +1,27 @@
1
- import streamlit as st
2
- from transformers import pipeline
3
- from PIL import Image
4
- import requests
5
- pip install transformers torch
6
 
7
 
8
- classifier = pipeline("image-classification", model="google/vit-base-patch16-224")
9
 
10
- def get_img_from_url(url):
11
- return Image.open(requests.get(url, stream=True).raw)
 
 
12
 
13
- def main():
14
- st.title("Image Classification")
15
 
16
- with st.form("image"):
17
- url = st.text_input("URL ของรูปภาพ", "https://images.livemint.com/img/2022/08/01/600x338/Cat-andriyko-podilnyk-RCfi7vgJjUY-unsplash_1659328989095_1659328998370_1659328998370.jpg")
18
- img = get_img_from_url(url)
19
- clicked = st.form_submit_button("ส่งคำขอ")
20
-
21
- if clicked:
22
- results = classifier(img)
23
- st.json(results)
 
 
 
 
 
 
24
 
25
- if __name__ == "__main__":
26
- main()
 
1
+ pip install invisible_watermark transformers accelerate safetensors
 
 
 
 
2
 
3
 
4
+ from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
5
 
6
+ pipe = StableDiffusionXLPipeline.from_pretrained(
7
+ "hotshotco/SDXL-512",
8
+ use_safetensors=True,
9
+ ).to('cuda')
10
 
11
+ pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
 
12
 
13
+ prompt = "a woman laughing"
14
+ negative_prompt = ""
15
+
16
+ image = pipe(
17
+ prompt,
18
+ negative_prompt=negative_prompt,
19
+ width=512,
20
+ height=512,
21
+ target_size=(1024, 1024),
22
+ original_size=(4096, 4096),
23
+ num_inference_steps=50
24
+ ).images[0]
25
+
26
+ image.save("woman_laughing.png")
27