weijiang2024 commited on
Commit
157d030
·
verified ·
1 Parent(s): b50a5d0

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. .DS_Store +0 -0
  2. README.md +6 -8
  3. app.py +37 -0
  4. requirements.txt +3 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
README.md CHANGED
@@ -1,12 +1,10 @@
1
  ---
2
- title: Suanfamama AIGC Alg2
3
- emoji: 📉
4
- colorFrom: pink
5
- colorTo: red
6
- sdk: gradio
7
- sdk_version: 4.37.2
8
  app_file: app.py
9
- pinned: false
 
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
1
  ---
2
+ title: Suanfamama_AIGC_alg2
 
 
 
 
 
3
  app_file: app.py
4
+ sdk: gradio
5
+ sdk_version: 4.29.0
6
  ---
7
 
8
+ # alg 算法
9
+ ## How to Deploy to Huggingface Spaces
10
+ * gradio deploy
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from diffusers import StableDiffusion3Pipeline
4
+
5
+ # Load the model
6
+ pipe = StableDiffusion3Pipeline.from_pretrained(
7
+ "stable-diffusion-3-medium-diffusers",
8
+ torch_dtype=torch.float16
9
+ )
10
+ pipe = pipe.to("cuda:1")
11
+
12
+ def generate_image(prompt, negative_prompt, num_inference_steps, guidance_scale):
13
+ # Generate the image
14
+ image = pipe(
15
+ prompt,
16
+ negative_prompt=negative_prompt,
17
+ num_inference_steps=num_inference_steps,
18
+ guidance_scale=guidance_scale
19
+ ).images[0]
20
+ return image
21
+
22
+ # Create the Gradio interface
23
+ interface = gr.Interface(
24
+ fn=generate_image,
25
+ inputs=[
26
+ gr.Textbox(label="Prompt"),
27
+ gr.Textbox(label="Negative Prompt", placeholder="Optional"),
28
+ gr.Slider(step=1, minimum=1, maximum=100, value=28, label="Number of Inference Steps"),
29
+ gr.Slider(minimum=1.0, maximum=20.0, step=0.1, value=7.0, label="Guidance Scale")
30
+ ],
31
+ outputs="image",
32
+ title="Stable Diffusion 3 Image Generator",
33
+ description="Generate images with Stable Diffusion 3. Type a prompt and see the magic!"
34
+ )
35
+
36
+ # Launch the interface
37
+ interface.launch(server_name="0.0.0.0", server_port=8912, inbrowser=True, share=False)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ torch
3
+ diffusers