Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,20 +16,19 @@ def ensure_flash_attn():
|
|
| 16 |
import flash_attn
|
| 17 |
print("当前 flash-attn 已安装,版本:", flash_attn.__version__)
|
| 18 |
except ImportError:
|
| 19 |
-
print("未安装 flash-attn
|
| 20 |
-
|
| 21 |
-
|
| 22 |
ensure_flash_attn()
|
| 23 |
from inferencer import UniPicV2Inferencer
|
| 24 |
|
| 25 |
os.environ["HF_HUB_REQUEST_TIMEOUT"] = "60.0"
|
| 26 |
model_path = snapshot_download(repo_id="Skywork/UniPic2-Metaquery-9B")
|
| 27 |
-
qwen_vl_path = snapshot_download(repo_id="Qwen/Qwen2.5-VL-7B-Instruct
|
| 28 |
|
| 29 |
inferencer = UniPicV2Inferencer(
|
| 30 |
model_path=model_path,
|
| 31 |
qwen_vl_path=qwen_vl_path,
|
| 32 |
-
quant="
|
| 33 |
)
|
| 34 |
#inferencer.pipeline = inferencer._init_pipeline()
|
| 35 |
|
|
@@ -69,7 +68,7 @@ def extract_assistant_reply(full_text):
|
|
| 69 |
return full_text.replace("<|im_end|>", "").strip()
|
| 70 |
|
| 71 |
|
| 72 |
-
def on_submit(history, user_msg, img_path, mode, infer_steps, cfg_scale, model_version='sd3.5-512', seed=
|
| 73 |
user_msg = user_msg.strip()
|
| 74 |
updated_history = history + [(user_msg, None)]
|
| 75 |
edit_tip = "✅ You can continue editing this image by switching the mode to 'Edit Image' and entering your instruction. "
|
|
@@ -244,7 +243,7 @@ with gr.Blocks(css=CSS) as demo:
|
|
| 244 |
img_state = gr.State(value=None)
|
| 245 |
|
| 246 |
with gr.Tabs():
|
| 247 |
-
with gr.Tab("Skywork UniPic2-Metaquery
|
| 248 |
chatbot = gr.Chatbot(
|
| 249 |
elem_id="chatbot1",
|
| 250 |
show_label=False,
|
|
@@ -309,9 +308,7 @@ with gr.Blocks(css=CSS) as demo:
|
|
| 309 |
)
|
| 310 |
clear_btn.click(clear_all, outputs=[chatbot, img_state, mode_selector])
|
| 311 |
|
| 312 |
-
demo.launch()
|
| 313 |
-
|
| 314 |
-
|
| 315 |
|
| 316 |
-
|
|
|
|
| 317 |
# demo.launch(server_name="0.0.0.0", debug=True, server_port=8004)
|
|
|
|
| 16 |
import flash_attn
|
| 17 |
print("当前 flash-attn 已安装,版本:", flash_attn.__version__)
|
| 18 |
except ImportError:
|
| 19 |
+
print("未安装 flash-attn")
|
| 20 |
+
|
|
|
|
| 21 |
ensure_flash_attn()
|
| 22 |
from inferencer import UniPicV2Inferencer
|
| 23 |
|
| 24 |
os.environ["HF_HUB_REQUEST_TIMEOUT"] = "60.0"
|
| 25 |
model_path = snapshot_download(repo_id="Skywork/UniPic2-Metaquery-9B")
|
| 26 |
+
qwen_vl_path = snapshot_download(repo_id="Qwen/Qwen2.5-VL-7B-Instruct")
|
| 27 |
|
| 28 |
inferencer = UniPicV2Inferencer(
|
| 29 |
model_path=model_path,
|
| 30 |
qwen_vl_path=qwen_vl_path,
|
| 31 |
+
quant="fp16"
|
| 32 |
)
|
| 33 |
#inferencer.pipeline = inferencer._init_pipeline()
|
| 34 |
|
|
|
|
| 68 |
return full_text.replace("<|im_end|>", "").strip()
|
| 69 |
|
| 70 |
|
| 71 |
+
def on_submit(history, user_msg, img_path, mode, infer_steps, cfg_scale, model_version='sd3.5-512', seed=3221):
|
| 72 |
user_msg = user_msg.strip()
|
| 73 |
updated_history = history + [(user_msg, None)]
|
| 74 |
edit_tip = "✅ You can continue editing this image by switching the mode to 'Edit Image' and entering your instruction. "
|
|
|
|
| 243 |
img_state = gr.State(value=None)
|
| 244 |
|
| 245 |
with gr.Tabs():
|
| 246 |
+
with gr.Tab("Skywork UniPic2-Metaquery", elem_id="tab_item_4"):
|
| 247 |
chatbot = gr.Chatbot(
|
| 248 |
elem_id="chatbot1",
|
| 249 |
show_label=False,
|
|
|
|
| 308 |
)
|
| 309 |
clear_btn.click(clear_all, outputs=[chatbot, img_state, mode_selector])
|
| 310 |
|
|
|
|
|
|
|
|
|
|
| 311 |
|
| 312 |
+
if __name__ == "__main__":
|
| 313 |
+
demo.launch()
|
| 314 |
# demo.launch(server_name="0.0.0.0", debug=True, server_port=8004)
|