georgekutty george commited on
Commit
472a47d
·
1 Parent(s): c3be90f
Files changed (2) hide show
  1. app.py +29 -0
  2. requirements.txt +7 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from diffusers import StableDiffusionPipeline
2
+ import gradio as gr
3
+ import torch
4
+
5
+ from huggingface_hub import login
6
+
7
+ # 3. Login to Hugging Face (replace YOUR_HF_TOKEN with your actual token)
8
+ login(token="YOUR_HF_TOKEN")
9
+
10
+ # 4. Load private model using your token
11
+ model_id = "Lookingsoft-team/Text_to_Image_Diffusion"
12
+
13
+ pipe = StableDiffusionPipeline.from_pretrained(
14
+ model_id,
15
+ torch_dtype=torch.float16 # smaller memory
16
+ ).to("cuda")
17
+
18
+ def generate_image(prompt):
19
+ image = pipe(prompt).images[0]
20
+ return image
21
+
22
+ iface = gr.Interface(
23
+ fn=generate_image,
24
+ inputs=gr.Textbox(label="Enter prompt"),
25
+ outputs=gr.Image(type="pil"),
26
+ title="Private Stable Diffusion Demo"
27
+ )
28
+
29
+ iface.launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ diffusers
2
+ transformers
3
+ torch
4
+ gradio
5
+ scipy
6
+ accelerate
7
+ safetensors