curry tang commited on
Commit
c33eba0
·
1 Parent(s): 108c4dc
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -6,6 +6,8 @@ from modelscope.outputs import OutputKeys
6
  from modelscope.pipelines import pipeline
7
  from modelscope.utils.constant import Tasks
8
  import cv2
 
 
9
 
10
 
11
  deep_seek_llm = DeepSeekLLM(api_key=settings.deep_seek_api_key)
@@ -69,6 +71,13 @@ def bg_remove(_image, _type):
69
  return vis_img
70
 
71
 
 
 
 
 
 
 
 
72
  with gr.Blocks() as app:
73
  with gr.Tab('聊天'):
74
  chat_engine = gr.State(value=None)
@@ -208,7 +217,7 @@ with gr.Blocks() as app:
208
  outputs=[chat_engine],
209
  )
210
 
211
- with gr.Tab('画图'):
212
  with gr.Row():
213
  with gr.Column(scale=2, min_width=600):
214
  image = gr.ImageMask(
@@ -228,5 +237,16 @@ with gr.Blocks() as app:
228
  object_remove_btn.click(fn=object_remove, inputs=[image, object_remove_refined], outputs=[image_preview, mask_preview])
229
  bg_remove_btn.click(fn=bg_remove, inputs=[image, bg_remove_type], outputs=[image_preview])
230
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
  app.launch(debug=settings.debug, show_api=False)
 
6
  from modelscope.pipelines import pipeline
7
  from modelscope.utils.constant import Tasks
8
  import cv2
9
+ from diffusers import StableDiffusionXLPipeline, StableDiffusionXLImg2ImgPipeline
10
+ import torch
11
 
12
 
13
  deep_seek_llm = DeepSeekLLM(api_key=settings.deep_seek_api_key)
 
71
  return vis_img
72
 
73
 
74
+ def text_to_image(_image, _prompt):
75
+ pipeline = StableDiffusionXLPipeline.from_single_file(
76
+ "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0.safetensors",
77
+ torch_dtype=torch.float16
78
+ ).to("cuda")
79
+ return _image
80
+
81
  with gr.Blocks() as app:
82
  with gr.Tab('聊天'):
83
  chat_engine = gr.State(value=None)
 
217
  outputs=[chat_engine],
218
  )
219
 
220
+ with gr.Tab('图像编辑'):
221
  with gr.Row():
222
  with gr.Column(scale=2, min_width=600):
223
  image = gr.ImageMask(
 
237
  object_remove_btn.click(fn=object_remove, inputs=[image, object_remove_refined], outputs=[image_preview, mask_preview])
238
  bg_remove_btn.click(fn=bg_remove, inputs=[image, bg_remove_type], outputs=[image_preview])
239
 
240
+ with gr.Tab('画图'):
241
+ with gr.Row():
242
+ with gr.Column(scale=2, min_width=600):
243
+ image = gr.Image()
244
+
245
+ with gr.Column(scale=1, min_width=300):
246
+ with gr.Accordion(label="图像生成"):
247
+ prompt = gr.Textbox(label="提示语", value="", lines=3)
248
+ t2i_btn = gr.Button('画图', variant='primary')
249
+ t2i_btn.click(fn=text_to_image, inputs=[prompt, image], outputs=[image])
250
+
251
 
252
  app.launch(debug=settings.debug, show_api=False)