SmallO commited on
Commit
866879a
1 Parent(s): 7e06337

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +45 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Untitled3.ipynb
3
+
4
+ Automatically generated by Colaboratory.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1eg0M7FRTlmONVU_5IaZH-EKADvdtODmT
8
+ """
9
+
10
+ #!pip install torch
11
+
12
+ #!pip install diffusers transformers accelerate torch
13
+
14
+ #!pip install streamlit
15
+
16
+ from diffusers import StableDiffusionPipeline
17
+ import torch
18
+ import streamlit as st
19
+
20
+ def pic_mo(prom):
21
+ model_id = "runwayml/stable-diffusion-v1-5"
22
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
23
+ pipe = pipe.to("cuda")
24
+
25
+ prompt = str(prom)
26
+
27
+ image = pipe(prompt).images[0]
28
+
29
+ return image
30
+
31
+ def main():
32
+ st.title("Text to Image with runwayml/stable-diffusion-v1-5")
33
+
34
+ # Input text prompt
35
+ title = st.text_input('Write a prompt', "")
36
+
37
+ if st.button('Generate Image'):
38
+ # Call the pic_mo function to generate an image
39
+ generated_image = pic_mo(title)
40
+
41
+ # Display the generated image
42
+ st.image(generated_image, caption='Generated Image', use_column_width=True)
43
+
44
+ if __name__ == '__main__':
45
+ main()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ python-dotenv