Ngene787 commited on
Commit
4d16190
·
1 Parent(s): 6a21f37

feat: add model

Browse files
Files changed (2) hide show
  1. app.py +13 -3
  2. stable_diffusion_inference.py +19 -0
app.py CHANGED
@@ -6,11 +6,21 @@
6
  @Project : Faice_text2face
7
  """
8
  import gradio as gr
 
9
 
10
 
11
- def greet(name):
12
- return "Hello " + name + "!!"
 
 
 
13
 
14
 
15
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
16
  demo.launch()
 
6
  @Project : Faice_text2face
7
  """
8
  import gradio as gr
9
+ from stable_diffusion_inference import inference
10
 
11
 
12
+ # def greet(name):
13
+ # return "Hello " + name + "!!"
14
+ #
15
+ #
16
+ # demo = gr.Interface(fn=greet, inputs="text", outputs="text")
17
 
18
 
19
+ def text2face(prompt):
20
+ image = inference(prompt)
21
+ return image
22
+
23
+
24
+ demo = gr.Interface(fn=text2face, inputs="text", outputs="image")
25
+
26
  demo.launch()
stable_diffusion_inference.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: UTF-8 -*-
2
+ """
3
+ @Time : 28/05/2025 11:56
4
+ @Author : xiaoguangliang
5
+ @File : stable_diffusion_inference.py
6
+ @Project : Faice_text2face
7
+ """
8
+ import torch
9
+ from diffusers import StableDiffusionPipeline
10
+
11
+ model_path = 'Ngene787/Faice_text2face'
12
+
13
+
14
+ def inference(prompt):
15
+ pipe = StableDiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float16)
16
+ # pipe = pipe.to("cuda")
17
+
18
+ image = pipe(prompt).images[0]
19
+ return image