curry tang commited on
Commit
7410b62
1 Parent(s): 6573f9c
Files changed (4) hide show
  1. app.py +22 -1
  2. pyproject.toml +6 -0
  3. requirements-dev.lock +49 -1
  4. requirements.lock +49 -1
app.py CHANGED
@@ -2,6 +2,9 @@ import gradio as gr
2
  from langchain_core.messages import HumanMessage, AIMessage
3
  from llm import DeepSeekLLM, OpenRouterLLM, TongYiLLM
4
  from config import settings
 
 
 
5
 
6
 
7
  deep_seek_llm = DeepSeekLLM(api_key=settings.deep_seek_api_key)
@@ -39,6 +42,17 @@ def update_chat(_provider: str, _chat, _model: str, _temperature: float, _max_to
39
  return _chat
40
 
41
 
 
 
 
 
 
 
 
 
 
 
 
42
  with gr.Blocks() as app:
43
  with gr.Tab('聊天'):
44
  chat_engine = gr.State(value=None)
@@ -176,7 +190,14 @@ with gr.Blocks() as app:
176
  with gr.Tab('画图'):
177
  with gr.Row():
178
  with gr.Column(scale=2, min_width=600):
179
- gr.Image(label="Input Image")
 
 
 
 
 
 
 
180
  with gr.Column(scale=1, min_width=300):
181
  gr.Textbox(label="LoRA")
182
 
 
2
  from langchain_core.messages import HumanMessage, AIMessage
3
  from llm import DeepSeekLLM, OpenRouterLLM, TongYiLLM
4
  from config import settings
5
+ from modelscope.outputs import OutputKeys
6
+ from modelscope.pipelines import pipeline
7
+ from modelscope.utils.constant import Tasks
8
 
9
 
10
  deep_seek_llm = DeepSeekLLM(api_key=settings.deep_seek_api_key)
 
42
  return _chat
43
 
44
 
45
+ def image_progress(_image):
46
+ _input = {
47
+ 'img': _image['background'],
48
+ 'mask': _image['layers'][0],
49
+ }
50
+ inpainting = pipeline(Tasks.image_inpainting, model='damo/cv_fft_inpainting_lama')
51
+ result = inpainting(_input)
52
+ vis_img = result[OutputKeys.OUTPUT_IMG]
53
+ return vis_img, _image['layers'][0]
54
+
55
+
56
  with gr.Blocks() as app:
57
  with gr.Tab('聊天'):
58
  chat_engine = gr.State(value=None)
 
190
  with gr.Tab('画图'):
191
  with gr.Row():
192
  with gr.Column(scale=2, min_width=600):
193
+ image = gr.ImageMask(
194
+ type='pil',
195
+ brush=gr.Brush(colors=["rgba(0, 0, 0, 0.7)"]),
196
+ )
197
+ with gr.Row():
198
+ image_preview = gr.Image(label='图片预览')
199
+ mask_preview = gr.Image(label='蒙板预览')
200
+ image.change(image_progress, inputs=[image], outputs=[image_preview, mask_preview])
201
  with gr.Column(scale=1, min_width=300):
202
  gr.Textbox(label="LoRA")
203
 
pyproject.toml CHANGED
@@ -13,6 +13,12 @@ dependencies = [
13
  "pydantic-settings>=2.3.4",
14
  "langchain-openai>=0.1.16",
15
  "dashscope>=1.20.1",
 
 
 
 
 
 
16
  ]
17
  readme = "README.md"
18
  requires-python = ">= 3.8"
 
13
  "pydantic-settings>=2.3.4",
14
  "langchain-openai>=0.1.16",
15
  "dashscope>=1.20.1",
16
+ "modelscope>=1.16.0",
17
+ "torch>=2.3.1",
18
+ "torchvision>=0.18.1",
19
+ "torchaudio>=2.3.1",
20
+ "setuptools>=71.0.0",
21
+ "oss2>=2.18.6",
22
  ]
23
  readme = "README.md"
24
  requires-python = ">= 3.8"
requirements-dev.lock CHANGED
@@ -16,6 +16,11 @@ aiohttp==3.9.5
16
  # via langchain
17
  aiosignal==1.3.1
18
  # via aiohttp
 
 
 
 
 
19
  altair==5.3.0
20
  # via gradio
21
  annotated-types==0.7.0
@@ -36,6 +41,8 @@ certifi==2024.7.4
36
  # via httpcore
37
  # via httpx
38
  # via requests
 
 
39
  charset-normalizer==3.3.2
40
  # via requests
41
  click==8.1.7
@@ -43,6 +50,10 @@ click==8.1.7
43
  # via uvicorn
44
  contourpy==1.2.1
45
  # via matplotlib
 
 
 
 
46
  cycler==0.12.1
47
  # via matplotlib
48
  dashscope==1.20.1
@@ -66,14 +77,16 @@ ffmpy==0.3.2
66
  filelock==3.15.4
67
  # via diffusers
68
  # via huggingface-hub
 
69
  fonttools==4.53.1
70
  # via matplotlib
71
  frozenlist==1.4.1
72
  # via aiohttp
73
  # via aiosignal
74
- fsspec==2024.6.1
75
  # via gradio-client
76
  # via huggingface-hub
 
77
  gradio==4.38.1
78
  # via aitoolkits-webui
79
  gradio-client==1.1.0
@@ -108,6 +121,9 @@ jinja2==3.1.4
108
  # via altair
109
  # via fastapi
110
  # via gradio
 
 
 
111
  jsonpatch==1.33
112
  # via langchain-core
113
  jsonpointer==3.0.0
@@ -140,9 +156,15 @@ matplotlib==3.9.1
140
  # via gradio
141
  mdurl==0.1.2
142
  # via markdown-it-py
 
 
 
 
143
  multidict==6.0.5
144
  # via aiohttp
145
  # via yarl
 
 
146
  numpy==1.26.4
147
  # via altair
148
  # via contourpy
@@ -151,12 +173,15 @@ numpy==1.26.4
151
  # via langchain
152
  # via matplotlib
153
  # via pandas
 
154
  openai==1.35.13
155
  # via langchain-openai
156
  orjson==3.10.6
157
  # via fastapi
158
  # via gradio
159
  # via langsmith
 
 
160
  packaging==24.1
161
  # via altair
162
  # via gradio
@@ -171,6 +196,11 @@ pillow==10.4.0
171
  # via diffusers
172
  # via gradio
173
  # via matplotlib
 
 
 
 
 
174
  pydantic==2.8.2
175
  # via aitoolkits-webui
176
  # via fastapi
@@ -219,6 +249,8 @@ requests==2.32.3
219
  # via huggingface-hub
220
  # via langchain
221
  # via langsmith
 
 
222
  # via tiktoken
223
  rich==13.7.1
224
  # via typer
@@ -231,9 +263,12 @@ safetensors==0.4.3
231
  # via diffusers
232
  semantic-version==2.10.0
233
  # via gradio
 
 
234
  shellingham==1.5.4
235
  # via typer
236
  six==1.16.0
 
237
  # via python-dateutil
238
  sniffio==1.3.1
239
  # via anyio
@@ -243,6 +278,8 @@ sqlalchemy==2.0.31
243
  # via langchain
244
  starlette==0.37.2
245
  # via fastapi
 
 
246
  tenacity==8.5.0
247
  # via langchain
248
  # via langchain-core
@@ -252,8 +289,17 @@ tomlkit==0.12.0
252
  # via gradio
253
  toolz==0.12.1
254
  # via altair
 
 
 
 
 
 
 
 
255
  tqdm==4.66.4
256
  # via huggingface-hub
 
257
  # via openai
258
  typer==0.12.3
259
  # via fastapi-cli
@@ -269,6 +315,7 @@ typing-extensions==4.12.2
269
  # via pydantic
270
  # via pydantic-core
271
  # via sqlalchemy
 
272
  # via typer
273
  # via uvicorn
274
  tzdata==2024.1
@@ -277,6 +324,7 @@ ujson==5.10.0
277
  # via fastapi
278
  urllib3==2.2.2
279
  # via gradio
 
280
  # via requests
281
  uvicorn==0.30.1
282
  # via fastapi
 
16
  # via langchain
17
  aiosignal==1.3.1
18
  # via aiohttp
19
+ aliyun-python-sdk-core==2.15.1
20
+ # via aliyun-python-sdk-kms
21
+ # via oss2
22
+ aliyun-python-sdk-kms==2.16.3
23
+ # via oss2
24
  altair==5.3.0
25
  # via gradio
26
  annotated-types==0.7.0
 
41
  # via httpcore
42
  # via httpx
43
  # via requests
44
+ cffi==1.16.0
45
+ # via cryptography
46
  charset-normalizer==3.3.2
47
  # via requests
48
  click==8.1.7
 
50
  # via uvicorn
51
  contourpy==1.2.1
52
  # via matplotlib
53
+ crcmod==1.7
54
+ # via oss2
55
+ cryptography==42.0.8
56
+ # via aliyun-python-sdk-core
57
  cycler==0.12.1
58
  # via matplotlib
59
  dashscope==1.20.1
 
77
  filelock==3.15.4
78
  # via diffusers
79
  # via huggingface-hub
80
+ # via torch
81
  fonttools==4.53.1
82
  # via matplotlib
83
  frozenlist==1.4.1
84
  # via aiohttp
85
  # via aiosignal
86
+ fsspec==2024.5.0
87
  # via gradio-client
88
  # via huggingface-hub
89
+ # via torch
90
  gradio==4.38.1
91
  # via aitoolkits-webui
92
  gradio-client==1.1.0
 
121
  # via altair
122
  # via fastapi
123
  # via gradio
124
+ # via torch
125
+ jmespath==0.10.0
126
+ # via aliyun-python-sdk-core
127
  jsonpatch==1.33
128
  # via langchain-core
129
  jsonpointer==3.0.0
 
156
  # via gradio
157
  mdurl==0.1.2
158
  # via markdown-it-py
159
+ modelscope==1.16.0
160
+ # via aitoolkits-webui
161
+ mpmath==1.3.0
162
+ # via sympy
163
  multidict==6.0.5
164
  # via aiohttp
165
  # via yarl
166
+ networkx==3.3
167
+ # via torch
168
  numpy==1.26.4
169
  # via altair
170
  # via contourpy
 
173
  # via langchain
174
  # via matplotlib
175
  # via pandas
176
+ # via torchvision
177
  openai==1.35.13
178
  # via langchain-openai
179
  orjson==3.10.6
180
  # via fastapi
181
  # via gradio
182
  # via langsmith
183
+ oss2==2.18.6
184
+ # via aitoolkits-webui
185
  packaging==24.1
186
  # via altair
187
  # via gradio
 
196
  # via diffusers
197
  # via gradio
198
  # via matplotlib
199
+ # via torchvision
200
+ pycparser==2.22
201
+ # via cffi
202
+ pycryptodome==3.20.0
203
+ # via oss2
204
  pydantic==2.8.2
205
  # via aitoolkits-webui
206
  # via fastapi
 
249
  # via huggingface-hub
250
  # via langchain
251
  # via langsmith
252
+ # via modelscope
253
+ # via oss2
254
  # via tiktoken
255
  rich==13.7.1
256
  # via typer
 
263
  # via diffusers
264
  semantic-version==2.10.0
265
  # via gradio
266
+ setuptools==71.0.0
267
+ # via aitoolkits-webui
268
  shellingham==1.5.4
269
  # via typer
270
  six==1.16.0
271
+ # via oss2
272
  # via python-dateutil
273
  sniffio==1.3.1
274
  # via anyio
 
278
  # via langchain
279
  starlette==0.37.2
280
  # via fastapi
281
+ sympy==1.13.0
282
+ # via torch
283
  tenacity==8.5.0
284
  # via langchain
285
  # via langchain-core
 
289
  # via gradio
290
  toolz==0.12.1
291
  # via altair
292
+ torch==2.3.1
293
+ # via aitoolkits-webui
294
+ # via torchaudio
295
+ # via torchvision
296
+ torchaudio==2.3.1
297
+ # via aitoolkits-webui
298
+ torchvision==0.18.1
299
+ # via aitoolkits-webui
300
  tqdm==4.66.4
301
  # via huggingface-hub
302
+ # via modelscope
303
  # via openai
304
  typer==0.12.3
305
  # via fastapi-cli
 
315
  # via pydantic
316
  # via pydantic-core
317
  # via sqlalchemy
318
+ # via torch
319
  # via typer
320
  # via uvicorn
321
  tzdata==2024.1
 
324
  # via fastapi
325
  urllib3==2.2.2
326
  # via gradio
327
+ # via modelscope
328
  # via requests
329
  uvicorn==0.30.1
330
  # via fastapi
requirements.lock CHANGED
@@ -16,6 +16,11 @@ aiohttp==3.9.5
16
  # via langchain
17
  aiosignal==1.3.1
18
  # via aiohttp
 
 
 
 
 
19
  altair==5.3.0
20
  # via gradio
21
  annotated-types==0.7.0
@@ -36,6 +41,8 @@ certifi==2024.7.4
36
  # via httpcore
37
  # via httpx
38
  # via requests
 
 
39
  charset-normalizer==3.3.2
40
  # via requests
41
  click==8.1.7
@@ -43,6 +50,10 @@ click==8.1.7
43
  # via uvicorn
44
  contourpy==1.2.1
45
  # via matplotlib
 
 
 
 
46
  cycler==0.12.1
47
  # via matplotlib
48
  dashscope==1.20.1
@@ -66,14 +77,16 @@ ffmpy==0.3.2
66
  filelock==3.15.4
67
  # via diffusers
68
  # via huggingface-hub
 
69
  fonttools==4.53.1
70
  # via matplotlib
71
  frozenlist==1.4.1
72
  # via aiohttp
73
  # via aiosignal
74
- fsspec==2024.6.1
75
  # via gradio-client
76
  # via huggingface-hub
 
77
  gradio==4.38.1
78
  # via aitoolkits-webui
79
  gradio-client==1.1.0
@@ -108,6 +121,9 @@ jinja2==3.1.4
108
  # via altair
109
  # via fastapi
110
  # via gradio
 
 
 
111
  jsonpatch==1.33
112
  # via langchain-core
113
  jsonpointer==3.0.0
@@ -140,9 +156,15 @@ matplotlib==3.9.1
140
  # via gradio
141
  mdurl==0.1.2
142
  # via markdown-it-py
 
 
 
 
143
  multidict==6.0.5
144
  # via aiohttp
145
  # via yarl
 
 
146
  numpy==1.26.4
147
  # via altair
148
  # via contourpy
@@ -151,12 +173,15 @@ numpy==1.26.4
151
  # via langchain
152
  # via matplotlib
153
  # via pandas
 
154
  openai==1.35.13
155
  # via langchain-openai
156
  orjson==3.10.6
157
  # via fastapi
158
  # via gradio
159
  # via langsmith
 
 
160
  packaging==24.1
161
  # via altair
162
  # via gradio
@@ -171,6 +196,11 @@ pillow==10.4.0
171
  # via diffusers
172
  # via gradio
173
  # via matplotlib
 
 
 
 
 
174
  pydantic==2.8.2
175
  # via aitoolkits-webui
176
  # via fastapi
@@ -219,6 +249,8 @@ requests==2.32.3
219
  # via huggingface-hub
220
  # via langchain
221
  # via langsmith
 
 
222
  # via tiktoken
223
  rich==13.7.1
224
  # via typer
@@ -231,9 +263,12 @@ safetensors==0.4.3
231
  # via diffusers
232
  semantic-version==2.10.0
233
  # via gradio
 
 
234
  shellingham==1.5.4
235
  # via typer
236
  six==1.16.0
 
237
  # via python-dateutil
238
  sniffio==1.3.1
239
  # via anyio
@@ -243,6 +278,8 @@ sqlalchemy==2.0.31
243
  # via langchain
244
  starlette==0.37.2
245
  # via fastapi
 
 
246
  tenacity==8.5.0
247
  # via langchain
248
  # via langchain-core
@@ -252,8 +289,17 @@ tomlkit==0.12.0
252
  # via gradio
253
  toolz==0.12.1
254
  # via altair
 
 
 
 
 
 
 
 
255
  tqdm==4.66.4
256
  # via huggingface-hub
 
257
  # via openai
258
  typer==0.12.3
259
  # via fastapi-cli
@@ -269,6 +315,7 @@ typing-extensions==4.12.2
269
  # via pydantic
270
  # via pydantic-core
271
  # via sqlalchemy
 
272
  # via typer
273
  # via uvicorn
274
  tzdata==2024.1
@@ -277,6 +324,7 @@ ujson==5.10.0
277
  # via fastapi
278
  urllib3==2.2.2
279
  # via gradio
 
280
  # via requests
281
  uvicorn==0.30.1
282
  # via fastapi
 
16
  # via langchain
17
  aiosignal==1.3.1
18
  # via aiohttp
19
+ aliyun-python-sdk-core==2.15.1
20
+ # via aliyun-python-sdk-kms
21
+ # via oss2
22
+ aliyun-python-sdk-kms==2.16.3
23
+ # via oss2
24
  altair==5.3.0
25
  # via gradio
26
  annotated-types==0.7.0
 
41
  # via httpcore
42
  # via httpx
43
  # via requests
44
+ cffi==1.16.0
45
+ # via cryptography
46
  charset-normalizer==3.3.2
47
  # via requests
48
  click==8.1.7
 
50
  # via uvicorn
51
  contourpy==1.2.1
52
  # via matplotlib
53
+ crcmod==1.7
54
+ # via oss2
55
+ cryptography==42.0.8
56
+ # via aliyun-python-sdk-core
57
  cycler==0.12.1
58
  # via matplotlib
59
  dashscope==1.20.1
 
77
  filelock==3.15.4
78
  # via diffusers
79
  # via huggingface-hub
80
+ # via torch
81
  fonttools==4.53.1
82
  # via matplotlib
83
  frozenlist==1.4.1
84
  # via aiohttp
85
  # via aiosignal
86
+ fsspec==2024.5.0
87
  # via gradio-client
88
  # via huggingface-hub
89
+ # via torch
90
  gradio==4.38.1
91
  # via aitoolkits-webui
92
  gradio-client==1.1.0
 
121
  # via altair
122
  # via fastapi
123
  # via gradio
124
+ # via torch
125
+ jmespath==0.10.0
126
+ # via aliyun-python-sdk-core
127
  jsonpatch==1.33
128
  # via langchain-core
129
  jsonpointer==3.0.0
 
156
  # via gradio
157
  mdurl==0.1.2
158
  # via markdown-it-py
159
+ modelscope==1.16.0
160
+ # via aitoolkits-webui
161
+ mpmath==1.3.0
162
+ # via sympy
163
  multidict==6.0.5
164
  # via aiohttp
165
  # via yarl
166
+ networkx==3.3
167
+ # via torch
168
  numpy==1.26.4
169
  # via altair
170
  # via contourpy
 
173
  # via langchain
174
  # via matplotlib
175
  # via pandas
176
+ # via torchvision
177
  openai==1.35.13
178
  # via langchain-openai
179
  orjson==3.10.6
180
  # via fastapi
181
  # via gradio
182
  # via langsmith
183
+ oss2==2.18.6
184
+ # via aitoolkits-webui
185
  packaging==24.1
186
  # via altair
187
  # via gradio
 
196
  # via diffusers
197
  # via gradio
198
  # via matplotlib
199
+ # via torchvision
200
+ pycparser==2.22
201
+ # via cffi
202
+ pycryptodome==3.20.0
203
+ # via oss2
204
  pydantic==2.8.2
205
  # via aitoolkits-webui
206
  # via fastapi
 
249
  # via huggingface-hub
250
  # via langchain
251
  # via langsmith
252
+ # via modelscope
253
+ # via oss2
254
  # via tiktoken
255
  rich==13.7.1
256
  # via typer
 
263
  # via diffusers
264
  semantic-version==2.10.0
265
  # via gradio
266
+ setuptools==71.0.0
267
+ # via aitoolkits-webui
268
  shellingham==1.5.4
269
  # via typer
270
  six==1.16.0
271
+ # via oss2
272
  # via python-dateutil
273
  sniffio==1.3.1
274
  # via anyio
 
278
  # via langchain
279
  starlette==0.37.2
280
  # via fastapi
281
+ sympy==1.13.0
282
+ # via torch
283
  tenacity==8.5.0
284
  # via langchain
285
  # via langchain-core
 
289
  # via gradio
290
  toolz==0.12.1
291
  # via altair
292
+ torch==2.3.1
293
+ # via aitoolkits-webui
294
+ # via torchaudio
295
+ # via torchvision
296
+ torchaudio==2.3.1
297
+ # via aitoolkits-webui
298
+ torchvision==0.18.1
299
+ # via aitoolkits-webui
300
  tqdm==4.66.4
301
  # via huggingface-hub
302
+ # via modelscope
303
  # via openai
304
  typer==0.12.3
305
  # via fastapi-cli
 
315
  # via pydantic
316
  # via pydantic-core
317
  # via sqlalchemy
318
+ # via torch
319
  # via typer
320
  # via uvicorn
321
  tzdata==2024.1
 
324
  # via fastapi
325
  urllib3==2.2.2
326
  # via gradio
327
+ # via modelscope
328
  # via requests
329
  uvicorn==0.30.1
330
  # via fastapi