Spaces:
Sleeping
Sleeping
Commit
·
f76dfc4
1
Parent(s):
9149125
add
Browse files- app.py +1 -1
- data.ipynb +536 -0
- requirements.txt +26 -0
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
def greet(name):
|
4 |
-
return "
|
5 |
|
6 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
def greet(name):
|
4 |
+
return "Chan " + name + "!!"
|
5 |
|
6 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
demo.launch()
|
data.ipynb
ADDED
@@ -0,0 +1,536 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 2,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"name": "stdout",
|
10 |
+
"output_type": "stream",
|
11 |
+
"text": [
|
12 |
+
"XIn chao\n"
|
13 |
+
]
|
14 |
+
}
|
15 |
+
],
|
16 |
+
"source": [
|
17 |
+
"import os\n",
|
18 |
+
"print(\"XIn chao\")"
|
19 |
+
]
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"cell_type": "code",
|
23 |
+
"execution_count": 3,
|
24 |
+
"metadata": {},
|
25 |
+
"outputs": [
|
26 |
+
{
|
27 |
+
"name": "stdout",
|
28 |
+
"output_type": "stream",
|
29 |
+
"text": [
|
30 |
+
"Requirement already satisfied: torch in /usr/local/lib/python3.10/site-packages (2.4.0)\n",
|
31 |
+
"Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/site-packages (from torch) (3.1.4)\n",
|
32 |
+
"Requirement already satisfied: nvidia-cublas-cu12==12.1.3.1 in /usr/local/lib/python3.10/site-packages (from torch) (12.1.3.1)\n",
|
33 |
+
"Requirement already satisfied: fsspec in /usr/local/lib/python3.10/site-packages (from torch) (2024.6.1)\n",
|
34 |
+
"Requirement already satisfied: nvidia-curand-cu12==10.3.2.106 in /usr/local/lib/python3.10/site-packages (from torch) (10.3.2.106)\n",
|
35 |
+
"Requirement already satisfied: nvidia-cusolver-cu12==11.4.5.107 in /usr/local/lib/python3.10/site-packages (from torch) (11.4.5.107)\n",
|
36 |
+
"Requirement already satisfied: sympy in /usr/local/lib/python3.10/site-packages (from torch) (1.13.3)\n",
|
37 |
+
"Requirement already satisfied: nvidia-cudnn-cu12==9.1.0.70 in /usr/local/lib/python3.10/site-packages (from torch) (9.1.0.70)\n",
|
38 |
+
"Requirement already satisfied: nvidia-cufft-cu12==11.0.2.54 in /usr/local/lib/python3.10/site-packages (from torch) (11.0.2.54)\n",
|
39 |
+
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/site-packages (from torch) (3.16.1)\n",
|
40 |
+
"Requirement already satisfied: typing-extensions>=4.8.0 in /usr/local/lib/python3.10/site-packages (from torch) (4.12.2)\n",
|
41 |
+
"Requirement already satisfied: nvidia-nvtx-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch) (12.1.105)\n",
|
42 |
+
"Requirement already satisfied: triton==3.0.0 in /usr/local/lib/python3.10/site-packages (from torch) (3.0.0)\n",
|
43 |
+
"Requirement already satisfied: nvidia-nccl-cu12==2.20.5 in /usr/local/lib/python3.10/site-packages (from torch) (2.20.5)\n",
|
44 |
+
"Requirement already satisfied: nvidia-cusparse-cu12==12.1.0.106 in /usr/local/lib/python3.10/site-packages (from torch) (12.1.0.106)\n",
|
45 |
+
"Requirement already satisfied: nvidia-cuda-cupti-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch) (12.1.105)\n",
|
46 |
+
"Requirement already satisfied: networkx in /usr/local/lib/python3.10/site-packages (from torch) (3.3)\n",
|
47 |
+
"Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch) (12.1.105)\n",
|
48 |
+
"Requirement already satisfied: nvidia-cuda-runtime-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch) (12.1.105)\n",
|
49 |
+
"Requirement already satisfied: nvidia-nvjitlink-cu12 in /usr/local/lib/python3.10/site-packages (from nvidia-cusolver-cu12==11.4.5.107->torch) (12.6.68)\n",
|
50 |
+
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/site-packages (from jinja2->torch) (2.1.5)\n",
|
51 |
+
"Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.10/site-packages (from sympy->torch) (1.3.0)\n",
|
52 |
+
"\n",
|
53 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
|
54 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
|
55 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
56 |
+
]
|
57 |
+
}
|
58 |
+
],
|
59 |
+
"source": [
|
60 |
+
"pip install torch\n"
|
61 |
+
]
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"cell_type": "code",
|
65 |
+
"execution_count": 7,
|
66 |
+
"metadata": {},
|
67 |
+
"outputs": [
|
68 |
+
{
|
69 |
+
"name": "stdout",
|
70 |
+
"output_type": "stream",
|
71 |
+
"text": [
|
72 |
+
"Không có GPU\n"
|
73 |
+
]
|
74 |
+
}
|
75 |
+
],
|
76 |
+
"source": [
|
77 |
+
"import torch\n",
|
78 |
+
"\n",
|
79 |
+
"# Kiểm tra xem có GPU hay không\n",
|
80 |
+
"if torch.cuda.is_available():\n",
|
81 |
+
" print(f\"GPU đang có sẵn: {torch.cuda.get_device_name(0)}\")\n",
|
82 |
+
"else:\n",
|
83 |
+
" print(\"Không có GPU\")\n"
|
84 |
+
]
|
85 |
+
},
|
86 |
+
{
|
87 |
+
"cell_type": "code",
|
88 |
+
"execution_count": 21,
|
89 |
+
"metadata": {},
|
90 |
+
"outputs": [
|
91 |
+
{
|
92 |
+
"ename": "OSError",
|
93 |
+
"evalue": "Cannot find empty port in range: 8083-8083. You can specify a different port by setting the GRADIO_SERVER_PORT environment variable or passing the `server_port` parameter to `launch()`.",
|
94 |
+
"output_type": "error",
|
95 |
+
"traceback": [
|
96 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
97 |
+
"\u001b[0;31mOSError\u001b[0m Traceback (most recent call last)",
|
98 |
+
"\u001b[1;32m/home/user/app/data.ipynb Cell 4\u001b[0m line \u001b[0;36m1\n\u001b[1;32m <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#W3sdnNjb2RlLXJlbW90ZQ%3D%3D?line=15'>16</a>\u001b[0m \u001b[39m# Chạy Gradio trên cổng 8080\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#W3sdnNjb2RlLXJlbW90ZQ%3D%3D?line=16'>17</a>\u001b[0m demo\u001b[39m.\u001b[39mshare \u001b[39m=\u001b[39m \u001b[39mTrue\u001b[39;00m\n\u001b[0;32m---> <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#W3sdnNjb2RlLXJlbW90ZQ%3D%3D?line=17'>18</a>\u001b[0m demo\u001b[39m.\u001b[39;49mlaunch(server_port\u001b[39m=\u001b[39;49m\u001b[39m8083\u001b[39;49m,share\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m)\n",
|
99 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/gradio/blocks.py:2515\u001b[0m, in \u001b[0;36mBlocks.launch\u001b[0;34m(self, inline, inbrowser, share, debug, max_threads, auth, auth_message, prevent_thread_lock, show_error, server_name, server_port, height, width, favicon_path, ssl_keyfile, ssl_certfile, ssl_keyfile_password, ssl_verify, quiet, show_api, allowed_paths, blocked_paths, root_path, app_kwargs, state_session_capacity, share_server_address, share_server_protocol, auth_dependency, max_file_size, enable_monitoring, strict_cors, node_server_name, node_port, ssr_mode, _frontend)\u001b[0m\n\u001b[1;32m 2507\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 2508\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mgradio\u001b[39;00m \u001b[39mimport\u001b[39;00m http_server\n\u001b[1;32m 2510\u001b[0m (\n\u001b[1;32m 2511\u001b[0m server_name,\n\u001b[1;32m 2512\u001b[0m server_port,\n\u001b[1;32m 2513\u001b[0m local_url,\n\u001b[1;32m 2514\u001b[0m server,\n\u001b[0;32m-> 2515\u001b[0m ) \u001b[39m=\u001b[39m http_server\u001b[39m.\u001b[39;49mstart_server(\n\u001b[1;32m 2516\u001b[0m app\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mapp,\n\u001b[1;32m 2517\u001b[0m server_name\u001b[39m=\u001b[39;49mserver_name,\n\u001b[1;32m 2518\u001b[0m server_port\u001b[39m=\u001b[39;49mserver_port,\n\u001b[1;32m 2519\u001b[0m ssl_keyfile\u001b[39m=\u001b[39;49mssl_keyfile,\n\u001b[1;32m 2520\u001b[0m ssl_certfile\u001b[39m=\u001b[39;49mssl_certfile,\n\u001b[1;32m 2521\u001b[0m ssl_keyfile_password\u001b[39m=\u001b[39;49mssl_keyfile_password,\n\u001b[1;32m 2522\u001b[0m )\n\u001b[1;32m 2523\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mserver_name \u001b[39m=\u001b[39m server_name\n\u001b[1;32m 2524\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mlocal_url \u001b[39m=\u001b[39m local_url\n",
|
100 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/gradio/http_server.py:156\u001b[0m, in \u001b[0;36mstart_server\u001b[0;34m(app, server_name, server_port, ssl_keyfile, ssl_certfile, ssl_keyfile_password)\u001b[0m\n\u001b[1;32m 154\u001b[0m \u001b[39mpass\u001b[39;00m\n\u001b[1;32m 155\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m--> 156\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mOSError\u001b[39;00m(\n\u001b[1;32m 157\u001b[0m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mCannot find empty port in range: \u001b[39m\u001b[39m{\u001b[39;00m\u001b[39mmin\u001b[39m(server_ports)\u001b[39m}\u001b[39;00m\u001b[39m-\u001b[39m\u001b[39m{\u001b[39;00m\u001b[39mmax\u001b[39m(server_ports)\u001b[39m}\u001b[39;00m\u001b[39m. You can specify a different port by setting the GRADIO_SERVER_PORT environment variable or passing the `server_port` parameter to `launch()`.\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 158\u001b[0m )\n\u001b[1;32m 160\u001b[0m \u001b[39mif\u001b[39;00m ssl_keyfile \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 161\u001b[0m path_to_local_server \u001b[39m=\u001b[39m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mhttps://\u001b[39m\u001b[39m{\u001b[39;00murl_host_name\u001b[39m}\u001b[39;00m\u001b[39m:\u001b[39m\u001b[39m{\u001b[39;00mport\u001b[39m}\u001b[39;00m\u001b[39m/\u001b[39m\u001b[39m\"\u001b[39m\n",
|
101 |
+
"\u001b[0;31mOSError\u001b[0m: Cannot find empty port in range: 8083-8083. You can specify a different port by setting the GRADIO_SERVER_PORT environment variable or passing the `server_port` parameter to `launch()`."
|
102 |
+
]
|
103 |
+
}
|
104 |
+
],
|
105 |
+
"source": [
|
106 |
+
"import gradio as gr\n",
|
107 |
+
"import os\n",
|
108 |
+
"\n",
|
109 |
+
"# Thiết lập cổng cho Gradio\n",
|
110 |
+
"os.environ[\"GRADIO_SERVER_PORT\"] = \"8080\"\n",
|
111 |
+
"\n",
|
112 |
+
"def greet(name, intensity):\n",
|
113 |
+
" return \"Hello, \" + name + \"!\" * int(intensity)\n",
|
114 |
+
"\n",
|
115 |
+
"demo = gr.Interface(\n",
|
116 |
+
" fn=greet,\n",
|
117 |
+
" inputs=[\"text\", \"slider\"],\n",
|
118 |
+
" outputs=[\"text\"],\n",
|
119 |
+
")\n",
|
120 |
+
"\n",
|
121 |
+
"# Chạy Gradio trên cổng 8080\n",
|
122 |
+
"demo.share = True\n",
|
123 |
+
"demo.launch(server_port=8083,share=True)\n"
|
124 |
+
]
|
125 |
+
},
|
126 |
+
{
|
127 |
+
"cell_type": "code",
|
128 |
+
"execution_count": 26,
|
129 |
+
"metadata": {},
|
130 |
+
"outputs": [
|
131 |
+
{
|
132 |
+
"ename": "ModuleNotFoundError",
|
133 |
+
"evalue": "No module named 'torchvision'",
|
134 |
+
"output_type": "error",
|
135 |
+
"traceback": [
|
136 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
137 |
+
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
|
138 |
+
"\u001b[1;32m/home/user/app/data.ipynb Cell 5\u001b[0m line \u001b[0;36m3\n\u001b[1;32m <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#W4sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mgradio\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mgr\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#W4sdnNjb2RlLXJlbW90ZQ%3D%3D?line=1'>2</a>\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mtorch\u001b[39;00m\n\u001b[0;32m----> <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#W4sdnNjb2RlLXJlbW90ZQ%3D%3D?line=2'>3</a>\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mtorchvision\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mmodels\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mmodels\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#W4sdnNjb2RlLXJlbW90ZQ%3D%3D?line=4'>5</a>\u001b[0m \u001b[39m# Kiểm tra xem GPU có sẵn không\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#W4sdnNjb2RlLXJlbW90ZQ%3D%3D?line=5'>6</a>\u001b[0m device \u001b[39m=\u001b[39m torch\u001b[39m.\u001b[39mdevice(\u001b[39m\"\u001b[39m\u001b[39mcuda\u001b[39m\u001b[39m\"\u001b[39m \u001b[39mif\u001b[39;00m torch\u001b[39m.\u001b[39mcuda\u001b[39m.\u001b[39mis_available() \u001b[39melse\u001b[39;00m \u001b[39m\"\u001b[39m\u001b[39mcpu\u001b[39m\u001b[39m\"\u001b[39m)\n",
|
139 |
+
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'torchvision'"
|
140 |
+
]
|
141 |
+
}
|
142 |
+
],
|
143 |
+
"source": [
|
144 |
+
"import gradio as gr\n",
|
145 |
+
"import torch\n",
|
146 |
+
"import torchvision.models as models\n",
|
147 |
+
"\n",
|
148 |
+
"# Kiểm tra xem GPU có sẵn không\n",
|
149 |
+
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
|
150 |
+
"\n",
|
151 |
+
"# Tải mô hình và chuyển sang GPU nếu có\n",
|
152 |
+
"model = models.resnet18(pretrained=True).to(device)\n",
|
153 |
+
"\n",
|
154 |
+
"# Hàm sử dụng GPU\n",
|
155 |
+
"def classify_image(image):\n",
|
156 |
+
" # Chuyển ảnh vào tensor và sử dụng GPU nếu có\n",
|
157 |
+
" image = image.to(device)\n",
|
158 |
+
" \n",
|
159 |
+
" # Dự đoán với mô hình\n",
|
160 |
+
" model.eval()\n",
|
161 |
+
" with torch.no_grad():\n",
|
162 |
+
" output = model(image)\n",
|
163 |
+
" \n",
|
164 |
+
" # Chuyển kết quả về CPU để dễ dàng hiển thị\n",
|
165 |
+
" output = output.cpu().numpy()\n",
|
166 |
+
" return output\n",
|
167 |
+
"\n",
|
168 |
+
"# Tạo giao diện Gradio\n",
|
169 |
+
"demo = gr.Interface(fn=classify_image, inputs=gr.inputs.Image(), outputs=\"label\")\n",
|
170 |
+
"\n",
|
171 |
+
"# Chạy ứng dụng Gradio\n",
|
172 |
+
"demo.launch(server_port=8086)\n"
|
173 |
+
]
|
174 |
+
},
|
175 |
+
{
|
176 |
+
"cell_type": "code",
|
177 |
+
"execution_count": 29,
|
178 |
+
"metadata": {},
|
179 |
+
"outputs": [],
|
180 |
+
"source": [
|
181 |
+
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")"
|
182 |
+
]
|
183 |
+
},
|
184 |
+
{
|
185 |
+
"cell_type": "code",
|
186 |
+
"execution_count": 31,
|
187 |
+
"metadata": {},
|
188 |
+
"outputs": [
|
189 |
+
{
|
190 |
+
"data": {
|
191 |
+
"text/plain": [
|
192 |
+
"device(type='cpu')"
|
193 |
+
]
|
194 |
+
},
|
195 |
+
"execution_count": 31,
|
196 |
+
"metadata": {},
|
197 |
+
"output_type": "execute_result"
|
198 |
+
}
|
199 |
+
],
|
200 |
+
"source": [
|
201 |
+
"device"
|
202 |
+
]
|
203 |
+
},
|
204 |
+
{
|
205 |
+
"cell_type": "code",
|
206 |
+
"execution_count": 33,
|
207 |
+
"metadata": {},
|
208 |
+
"outputs": [
|
209 |
+
{
|
210 |
+
"data": {
|
211 |
+
"text/plain": [
|
212 |
+
"False"
|
213 |
+
]
|
214 |
+
},
|
215 |
+
"execution_count": 33,
|
216 |
+
"metadata": {},
|
217 |
+
"output_type": "execute_result"
|
218 |
+
}
|
219 |
+
],
|
220 |
+
"source": [
|
221 |
+
"torch.cuda.is_available() "
|
222 |
+
]
|
223 |
+
},
|
224 |
+
{
|
225 |
+
"cell_type": "code",
|
226 |
+
"execution_count": 35,
|
227 |
+
"metadata": {},
|
228 |
+
"outputs": [
|
229 |
+
{
|
230 |
+
"name": "stdout",
|
231 |
+
"output_type": "stream",
|
232 |
+
"text": [
|
233 |
+
"Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com\n",
|
234 |
+
"Collecting diffusers\n",
|
235 |
+
" Downloading diffusers-0.32.1-py3-none-any.whl (3.2 MB)\n",
|
236 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.2/3.2 MB\u001b[0m \u001b[31m62.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",
|
237 |
+
"\u001b[?25hCollecting safetensors>=0.3.1\n",
|
238 |
+
" Downloading safetensors-0.4.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (435 kB)\n",
|
239 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m435.0/435.0 kB\u001b[0m \u001b[31m45.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
240 |
+
"\u001b[?25hRequirement already satisfied: requests in /usr/local/lib/python3.10/site-packages (from diffusers) (2.32.3)\n",
|
241 |
+
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/site-packages (from diffusers) (2.1.1)\n",
|
242 |
+
"Collecting regex!=2019.12.17\n",
|
243 |
+
" Downloading regex-2024.11.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (781 kB)\n",
|
244 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m781.7/781.7 kB\u001b[0m \u001b[31m196.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
245 |
+
"\u001b[?25hRequirement already satisfied: filelock in /usr/local/lib/python3.10/site-packages (from diffusers) (3.16.1)\n",
|
246 |
+
"Collecting importlib-metadata\n",
|
247 |
+
" Downloading importlib_metadata-8.5.0-py3-none-any.whl (26 kB)\n",
|
248 |
+
"Requirement already satisfied: huggingface-hub>=0.23.2 in /usr/local/lib/python3.10/site-packages (from diffusers) (0.25.1)\n",
|
249 |
+
"Requirement already satisfied: Pillow in /usr/local/lib/python3.10/site-packages (from diffusers) (11.0.0)\n",
|
250 |
+
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.23.2->diffusers) (6.0.2)\n",
|
251 |
+
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.23.2->diffusers) (2024.6.1)\n",
|
252 |
+
"Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.23.2->diffusers) (24.1)\n",
|
253 |
+
"Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.23.2->diffusers) (4.66.5)\n",
|
254 |
+
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.23.2->diffusers) (4.12.2)\n",
|
255 |
+
"Collecting zipp>=3.20\n",
|
256 |
+
" Downloading zipp-3.21.0-py3-none-any.whl (9.6 kB)\n",
|
257 |
+
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/site-packages (from requests->diffusers) (2.2.3)\n",
|
258 |
+
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/site-packages (from requests->diffusers) (2024.8.30)\n",
|
259 |
+
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/site-packages (from requests->diffusers) (3.3.2)\n",
|
260 |
+
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/site-packages (from requests->diffusers) (3.10)\n",
|
261 |
+
"Installing collected packages: zipp, safetensors, regex, importlib-metadata, diffusers\n",
|
262 |
+
"Successfully installed diffusers-0.32.1 importlib-metadata-8.5.0 regex-2024.11.6 safetensors-0.4.5 zipp-3.21.0\n",
|
263 |
+
"\n",
|
264 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
|
265 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
|
266 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
267 |
+
]
|
268 |
+
}
|
269 |
+
],
|
270 |
+
"source": [
|
271 |
+
"pip install diffusers"
|
272 |
+
]
|
273 |
+
},
|
274 |
+
{
|
275 |
+
"cell_type": "code",
|
276 |
+
"execution_count": 40,
|
277 |
+
"metadata": {},
|
278 |
+
"outputs": [
|
279 |
+
{
|
280 |
+
"name": "stdout",
|
281 |
+
"output_type": "stream",
|
282 |
+
"text": [
|
283 |
+
"Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com\n",
|
284 |
+
"Requirement already satisfied: accelerate in /usr/local/lib/python3.10/site-packages (1.2.1)\n",
|
285 |
+
"Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/site-packages (from accelerate) (24.1)\n",
|
286 |
+
"Requirement already satisfied: pyyaml in /usr/local/lib/python3.10/site-packages (from accelerate) (6.0.2)\n",
|
287 |
+
"Requirement already satisfied: psutil in /usr/local/lib/python3.10/site-packages (from accelerate) (5.9.8)\n",
|
288 |
+
"Requirement already satisfied: huggingface-hub>=0.21.0 in /usr/local/lib/python3.10/site-packages (from accelerate) (0.25.1)\n",
|
289 |
+
"Requirement already satisfied: safetensors>=0.4.3 in /usr/local/lib/python3.10/site-packages (from accelerate) (0.4.5)\n",
|
290 |
+
"Requirement already satisfied: numpy<3.0.0,>=1.17 in /usr/local/lib/python3.10/site-packages (from accelerate) (2.1.1)\n",
|
291 |
+
"Requirement already satisfied: torch>=1.10.0 in /usr/local/lib/python3.10/site-packages (from accelerate) (2.4.0)\n",
|
292 |
+
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.21.0->accelerate) (2024.6.1)\n",
|
293 |
+
"Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.21.0->accelerate) (4.66.5)\n",
|
294 |
+
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.21.0->accelerate) (3.16.1)\n",
|
295 |
+
"Requirement already satisfied: requests in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.21.0->accelerate) (2.32.3)\n",
|
296 |
+
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.21.0->accelerate) (4.12.2)\n",
|
297 |
+
"Requirement already satisfied: nvidia-cusolver-cu12==11.4.5.107 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (11.4.5.107)\n",
|
298 |
+
"Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (3.1.4)\n",
|
299 |
+
"Requirement already satisfied: nvidia-cublas-cu12==12.1.3.1 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (12.1.3.1)\n",
|
300 |
+
"Requirement already satisfied: nvidia-cuda-cupti-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (12.1.105)\n",
|
301 |
+
"Requirement already satisfied: nvidia-cudnn-cu12==9.1.0.70 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (9.1.0.70)\n",
|
302 |
+
"Requirement already satisfied: nvidia-nccl-cu12==2.20.5 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (2.20.5)\n",
|
303 |
+
"Requirement already satisfied: nvidia-nvtx-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (12.1.105)\n",
|
304 |
+
"Requirement already satisfied: networkx in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (3.3)\n",
|
305 |
+
"Requirement already satisfied: nvidia-cusparse-cu12==12.1.0.106 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (12.1.0.106)\n",
|
306 |
+
"Requirement already satisfied: nvidia-cufft-cu12==11.0.2.54 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (11.0.2.54)\n",
|
307 |
+
"Requirement already satisfied: nvidia-cuda-runtime-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (12.1.105)\n",
|
308 |
+
"Requirement already satisfied: sympy in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (1.13.3)\n",
|
309 |
+
"Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (12.1.105)\n",
|
310 |
+
"Requirement already satisfied: nvidia-curand-cu12==10.3.2.106 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (10.3.2.106)\n",
|
311 |
+
"Requirement already satisfied: triton==3.0.0 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (3.0.0)\n",
|
312 |
+
"Requirement already satisfied: nvidia-nvjitlink-cu12 in /usr/local/lib/python3.10/site-packages (from nvidia-cusolver-cu12==11.4.5.107->torch>=1.10.0->accelerate) (12.6.68)\n",
|
313 |
+
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/site-packages (from jinja2->torch>=1.10.0->accelerate) (2.1.5)\n",
|
314 |
+
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.21.0->accelerate) (3.3.2)\n",
|
315 |
+
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.21.0->accelerate) (3.10)\n",
|
316 |
+
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.21.0->accelerate) (2024.8.30)\n",
|
317 |
+
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.21.0->accelerate) (2.2.3)\n",
|
318 |
+
"Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.10/site-packages (from sympy->torch>=1.10.0->accelerate) (1.3.0)\n",
|
319 |
+
"\n",
|
320 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
|
321 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
|
322 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
323 |
+
]
|
324 |
+
}
|
325 |
+
],
|
326 |
+
"source": [
|
327 |
+
"pip install accelerate"
|
328 |
+
]
|
329 |
+
},
|
330 |
+
{
|
331 |
+
"cell_type": "code",
|
332 |
+
"execution_count": 37,
|
333 |
+
"metadata": {},
|
334 |
+
"outputs": [
|
335 |
+
{
|
336 |
+
"name": "stdout",
|
337 |
+
"output_type": "stream",
|
338 |
+
"text": [
|
339 |
+
"Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com\n",
|
340 |
+
"Collecting accelerate\n",
|
341 |
+
" Downloading accelerate-1.2.1-py3-none-any.whl (336 kB)\n",
|
342 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m336.4/336.4 kB\u001b[0m \u001b[31m22.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
343 |
+
"\u001b[?25hRequirement already satisfied: torch>=1.10.0 in /usr/local/lib/python3.10/site-packages (from accelerate) (2.4.0)\n",
|
344 |
+
"Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/site-packages (from accelerate) (24.1)\n",
|
345 |
+
"Requirement already satisfied: pyyaml in /usr/local/lib/python3.10/site-packages (from accelerate) (6.0.2)\n",
|
346 |
+
"Requirement already satisfied: psutil in /usr/local/lib/python3.10/site-packages (from accelerate) (5.9.8)\n",
|
347 |
+
"Requirement already satisfied: numpy<3.0.0,>=1.17 in /usr/local/lib/python3.10/site-packages (from accelerate) (2.1.1)\n",
|
348 |
+
"Requirement already satisfied: safetensors>=0.4.3 in /usr/local/lib/python3.10/site-packages (from accelerate) (0.4.5)\n",
|
349 |
+
"Requirement already satisfied: huggingface-hub>=0.21.0 in /usr/local/lib/python3.10/site-packages (from accelerate) (0.25.1)\n",
|
350 |
+
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.21.0->accelerate) (3.16.1)\n",
|
351 |
+
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.21.0->accelerate) (4.12.2)\n",
|
352 |
+
"Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.21.0->accelerate) (4.66.5)\n",
|
353 |
+
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.21.0->accelerate) (2024.6.1)\n",
|
354 |
+
"Requirement already satisfied: requests in /usr/local/lib/python3.10/site-packages (from huggingface-hub>=0.21.0->accelerate) (2.32.3)\n",
|
355 |
+
"Requirement already satisfied: nvidia-cudnn-cu12==9.1.0.70 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (9.1.0.70)\n",
|
356 |
+
"Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (12.1.105)\n",
|
357 |
+
"Requirement already satisfied: nvidia-cufft-cu12==11.0.2.54 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (11.0.2.54)\n",
|
358 |
+
"Requirement already satisfied: nvidia-cublas-cu12==12.1.3.1 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (12.1.3.1)\n",
|
359 |
+
"Requirement already satisfied: triton==3.0.0 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (3.0.0)\n",
|
360 |
+
"Requirement already satisfied: nvidia-nccl-cu12==2.20.5 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (2.20.5)\n",
|
361 |
+
"Requirement already satisfied: networkx in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (3.3)\n",
|
362 |
+
"Requirement already satisfied: nvidia-curand-cu12==10.3.2.106 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (10.3.2.106)\n",
|
363 |
+
"Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (3.1.4)\n",
|
364 |
+
"Requirement already satisfied: nvidia-cuda-runtime-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (12.1.105)\n",
|
365 |
+
"Requirement already satisfied: nvidia-nvtx-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (12.1.105)\n",
|
366 |
+
"Requirement already satisfied: nvidia-cuda-cupti-cu12==12.1.105 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (12.1.105)\n",
|
367 |
+
"Requirement already satisfied: nvidia-cusparse-cu12==12.1.0.106 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (12.1.0.106)\n",
|
368 |
+
"Requirement already satisfied: nvidia-cusolver-cu12==11.4.5.107 in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (11.4.5.107)\n",
|
369 |
+
"Requirement already satisfied: sympy in /usr/local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (1.13.3)\n",
|
370 |
+
"Requirement already satisfied: nvidia-nvjitlink-cu12 in /usr/local/lib/python3.10/site-packages (from nvidia-cusolver-cu12==11.4.5.107->torch>=1.10.0->accelerate) (12.6.68)\n",
|
371 |
+
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/site-packages (from jinja2->torch>=1.10.0->accelerate) (2.1.5)\n",
|
372 |
+
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.21.0->accelerate) (2.2.3)\n",
|
373 |
+
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.21.0->accelerate) (3.10)\n",
|
374 |
+
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.21.0->accelerate) (2024.8.30)\n",
|
375 |
+
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.21.0->accelerate) (3.3.2)\n",
|
376 |
+
"Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.10/site-packages (from sympy->torch>=1.10.0->accelerate) (1.3.0)\n",
|
377 |
+
"Installing collected packages: accelerate\n",
|
378 |
+
"Successfully installed accelerate-1.2.1\n",
|
379 |
+
"\n",
|
380 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
|
381 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
|
382 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
383 |
+
]
|
384 |
+
}
|
385 |
+
],
|
386 |
+
"source": [
|
387 |
+
"pip install accelerate"
|
388 |
+
]
|
389 |
+
},
|
390 |
+
{
|
391 |
+
"cell_type": "code",
|
392 |
+
"execution_count": 5,
|
393 |
+
"metadata": {},
|
394 |
+
"outputs": [
|
395 |
+
{
|
396 |
+
"ename": "EntryNotFoundError",
|
397 |
+
"evalue": "404 Client Error. (Request ID: Root=1-676e30f5-6503b00035cc3c54406f318b;5089af88-596d-48a4-9917-100d2a940357)\n\nEntry Not Found for url: https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/model_index.json.",
|
398 |
+
"output_type": "error",
|
399 |
+
"traceback": [
|
400 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
401 |
+
"\u001b[0;31mHTTPError\u001b[0m Traceback (most recent call last)",
|
402 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:406\u001b[0m, in \u001b[0;36mhf_raise_for_status\u001b[0;34m(response, endpoint_name)\u001b[0m\n\u001b[1;32m 405\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 406\u001b[0m response\u001b[39m.\u001b[39;49mraise_for_status()\n\u001b[1;32m 407\u001b[0m \u001b[39mexcept\u001b[39;00m HTTPError \u001b[39mas\u001b[39;00m e:\n",
|
403 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/requests/models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 1023\u001b[0m \u001b[39mif\u001b[39;00m http_error_msg:\n\u001b[0;32m-> 1024\u001b[0m \u001b[39mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m)\n",
|
404 |
+
"\u001b[0;31mHTTPError\u001b[0m: 404 Client Error: Not Found for url: https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/model_index.json",
|
405 |
+
"\nThe above exception was the direct cause of the following exception:\n",
|
406 |
+
"\u001b[0;31mEntryNotFoundError\u001b[0m Traceback (most recent call last)",
|
407 |
+
"\u001b[1;32m/home/user/app/data.ipynb Cell 12\u001b[0m line \u001b[0;36m6\n\u001b[1;32m <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=2'>3</a>\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mdiffusers\u001b[39;00m \u001b[39mimport\u001b[39;00m DiffusionPipeline\n\u001b[1;32m <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=4'>5</a>\u001b[0m \u001b[39m# Tải mô hình Diffusion, thay thế 'your_model_name_or_path' bằng tên hoặc đường dẫn mô hình của bạn\u001b[39;00m\n\u001b[0;32m----> <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=5'>6</a>\u001b[0m pipe \u001b[39m=\u001b[39m DiffusionPipeline\u001b[39m.\u001b[39;49mfrom_pretrained(\u001b[39m\"\u001b[39;49m\u001b[39mCompVis/stable-diffusion-v-1-4-original\u001b[39;49m\u001b[39m\"\u001b[39;49m)\n\u001b[1;32m <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=6'>7</a>\u001b[0m pipe\u001b[39m.\u001b[39mto(\u001b[39m'\u001b[39m\u001b[39mcuda\u001b[39m\u001b[39m'\u001b[39m) \u001b[39m# Chuyển mô hình sang GPU nếu có\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://trinhvanhung-zeogpu--1027.hf.space/home/user/app/data.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=8'>9</a>\u001b[0m \u001b[39m# Hàm để sinh ảnh từ prompt\u001b[39;00m\n",
|
408 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114\u001b[0m, in \u001b[0;36mvalidate_hf_hub_args.<locals>._inner_fn\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[39mif\u001b[39;00m check_use_auth_token:\n\u001b[1;32m 112\u001b[0m kwargs \u001b[39m=\u001b[39m smoothly_deprecate_use_auth_token(fn_name\u001b[39m=\u001b[39mfn\u001b[39m.\u001b[39m\u001b[39m__name__\u001b[39m, has_token\u001b[39m=\u001b[39mhas_token, kwargs\u001b[39m=\u001b[39mkwargs)\n\u001b[0;32m--> 114\u001b[0m \u001b[39mreturn\u001b[39;00m fn(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n",
|
409 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/diffusers/pipelines/pipeline_utils.py:732\u001b[0m, in \u001b[0;36mDiffusionPipeline.from_pretrained\u001b[0;34m(cls, pretrained_model_name_or_path, **kwargs)\u001b[0m\n\u001b[1;32m 727\u001b[0m \u001b[39mif\u001b[39;00m pretrained_model_name_or_path\u001b[39m.\u001b[39mcount(\u001b[39m\"\u001b[39m\u001b[39m/\u001b[39m\u001b[39m\"\u001b[39m) \u001b[39m>\u001b[39m \u001b[39m1\u001b[39m:\n\u001b[1;32m 728\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\n\u001b[1;32m 729\u001b[0m \u001b[39mf\u001b[39m\u001b[39m'\u001b[39m\u001b[39mThe provided pretrained_model_name_or_path \u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00mpretrained_model_name_or_path\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m\u001b[39m'\u001b[39m\n\u001b[1;32m 730\u001b[0m \u001b[39m\"\u001b[39m\u001b[39m is neither a valid local path nor a valid repo id. Please check the parameter.\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 731\u001b[0m )\n\u001b[0;32m--> 732\u001b[0m cached_folder \u001b[39m=\u001b[39m \u001b[39mcls\u001b[39;49m\u001b[39m.\u001b[39;49mdownload(\n\u001b[1;32m 733\u001b[0m pretrained_model_name_or_path,\n\u001b[1;32m 734\u001b[0m cache_dir\u001b[39m=\u001b[39;49mcache_dir,\n\u001b[1;32m 735\u001b[0m force_download\u001b[39m=\u001b[39;49mforce_download,\n\u001b[1;32m 736\u001b[0m proxies\u001b[39m=\u001b[39;49mproxies,\n\u001b[1;32m 737\u001b[0m local_files_only\u001b[39m=\u001b[39;49mlocal_files_only,\n\u001b[1;32m 738\u001b[0m token\u001b[39m=\u001b[39;49mtoken,\n\u001b[1;32m 739\u001b[0m revision\u001b[39m=\u001b[39;49mrevision,\n\u001b[1;32m 740\u001b[0m from_flax\u001b[39m=\u001b[39;49mfrom_flax,\n\u001b[1;32m 741\u001b[0m use_safetensors\u001b[39m=\u001b[39;49muse_safetensors,\n\u001b[1;32m 742\u001b[0m use_onnx\u001b[39m=\u001b[39;49muse_onnx,\n\u001b[1;32m 743\u001b[0m custom_pipeline\u001b[39m=\u001b[39;49mcustom_pipeline,\n\u001b[1;32m 744\u001b[0m custom_revision\u001b[39m=\u001b[39;49mcustom_revision,\n\u001b[1;32m 745\u001b[0m variant\u001b[39m=\u001b[39;49mvariant,\n\u001b[1;32m 746\u001b[0m load_connected_pipeline\u001b[39m=\u001b[39;49mload_connected_pipeline,\n\u001b[1;32m 747\u001b[0m \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs,\n\u001b[1;32m 748\u001b[0m )\n\u001b[1;32m 749\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 750\u001b[0m cached_folder \u001b[39m=\u001b[39m pretrained_model_name_or_path\n",
|
410 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114\u001b[0m, in \u001b[0;36mvalidate_hf_hub_args.<locals>._inner_fn\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[39mif\u001b[39;00m check_use_auth_token:\n\u001b[1;32m 112\u001b[0m kwargs \u001b[39m=\u001b[39m smoothly_deprecate_use_auth_token(fn_name\u001b[39m=\u001b[39mfn\u001b[39m.\u001b[39m\u001b[39m__name__\u001b[39m, has_token\u001b[39m=\u001b[39mhas_token, kwargs\u001b[39m=\u001b[39mkwargs)\n\u001b[0;32m--> 114\u001b[0m \u001b[39mreturn\u001b[39;00m fn(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n",
|
411 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/diffusers/pipelines/pipeline_utils.py:1333\u001b[0m, in \u001b[0;36mDiffusionPipeline.download\u001b[0;34m(cls, pretrained_model_name, **kwargs)\u001b[0m\n\u001b[1;32m 1329\u001b[0m logger\u001b[39m.\u001b[39mwarning(warn_msg)\n\u001b[1;32m 1331\u001b[0m model_filenames, variant_filenames \u001b[39m=\u001b[39m variant_compatible_siblings(filenames, variant\u001b[39m=\u001b[39mvariant)\n\u001b[0;32m-> 1333\u001b[0m config_file \u001b[39m=\u001b[39m hf_hub_download(\n\u001b[1;32m 1334\u001b[0m pretrained_model_name,\n\u001b[1;32m 1335\u001b[0m \u001b[39mcls\u001b[39;49m\u001b[39m.\u001b[39;49mconfig_name,\n\u001b[1;32m 1336\u001b[0m cache_dir\u001b[39m=\u001b[39;49mcache_dir,\n\u001b[1;32m 1337\u001b[0m revision\u001b[39m=\u001b[39;49mrevision,\n\u001b[1;32m 1338\u001b[0m proxies\u001b[39m=\u001b[39;49mproxies,\n\u001b[1;32m 1339\u001b[0m force_download\u001b[39m=\u001b[39;49mforce_download,\n\u001b[1;32m 1340\u001b[0m token\u001b[39m=\u001b[39;49mtoken,\n\u001b[1;32m 1341\u001b[0m )\n\u001b[1;32m 1343\u001b[0m config_dict \u001b[39m=\u001b[39m \u001b[39mcls\u001b[39m\u001b[39m.\u001b[39m_dict_from_json_file(config_file)\n\u001b[1;32m 1344\u001b[0m ignore_filenames \u001b[39m=\u001b[39m config_dict\u001b[39m.\u001b[39mpop(\u001b[39m\"\u001b[39m\u001b[39m_ignore_files\u001b[39m\u001b[39m\"\u001b[39m, [])\n",
|
412 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/utils/_deprecation.py:101\u001b[0m, in \u001b[0;36m_deprecate_arguments.<locals>._inner_deprecate_positional_args.<locals>.inner_f\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 99\u001b[0m message \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m\\n\u001b[39;00m\u001b[39m\"\u001b[39m \u001b[39m+\u001b[39m custom_message\n\u001b[1;32m 100\u001b[0m warnings\u001b[39m.\u001b[39mwarn(message, \u001b[39mFutureWarning\u001b[39;00m)\n\u001b[0;32m--> 101\u001b[0m \u001b[39mreturn\u001b[39;00m f(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n",
|
413 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114\u001b[0m, in \u001b[0;36mvalidate_hf_hub_args.<locals>._inner_fn\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[39mif\u001b[39;00m check_use_auth_token:\n\u001b[1;32m 112\u001b[0m kwargs \u001b[39m=\u001b[39m smoothly_deprecate_use_auth_token(fn_name\u001b[39m=\u001b[39mfn\u001b[39m.\u001b[39m\u001b[39m__name__\u001b[39m, has_token\u001b[39m=\u001b[39mhas_token, kwargs\u001b[39m=\u001b[39mkwargs)\n\u001b[0;32m--> 114\u001b[0m \u001b[39mreturn\u001b[39;00m fn(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n",
|
414 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/file_download.py:1232\u001b[0m, in \u001b[0;36mhf_hub_download\u001b[0;34m(repo_id, filename, subfolder, repo_type, revision, library_name, library_version, cache_dir, local_dir, user_agent, force_download, proxies, etag_timeout, token, local_files_only, headers, endpoint, legacy_cache_layout, resume_download, force_filename, local_dir_use_symlinks)\u001b[0m\n\u001b[1;32m 1212\u001b[0m \u001b[39mreturn\u001b[39;00m _hf_hub_download_to_local_dir(\n\u001b[1;32m 1213\u001b[0m \u001b[39m# Destination\u001b[39;00m\n\u001b[1;32m 1214\u001b[0m local_dir\u001b[39m=\u001b[39mlocal_dir,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1229\u001b[0m local_files_only\u001b[39m=\u001b[39mlocal_files_only,\n\u001b[1;32m 1230\u001b[0m )\n\u001b[1;32m 1231\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m-> 1232\u001b[0m \u001b[39mreturn\u001b[39;00m _hf_hub_download_to_cache_dir(\n\u001b[1;32m 1233\u001b[0m \u001b[39m# Destination\u001b[39;49;00m\n\u001b[1;32m 1234\u001b[0m cache_dir\u001b[39m=\u001b[39;49mcache_dir,\n\u001b[1;32m 1235\u001b[0m \u001b[39m# File info\u001b[39;49;00m\n\u001b[1;32m 1236\u001b[0m repo_id\u001b[39m=\u001b[39;49mrepo_id,\n\u001b[1;32m 1237\u001b[0m filename\u001b[39m=\u001b[39;49mfilename,\n\u001b[1;32m 1238\u001b[0m repo_type\u001b[39m=\u001b[39;49mrepo_type,\n\u001b[1;32m 1239\u001b[0m revision\u001b[39m=\u001b[39;49mrevision,\n\u001b[1;32m 1240\u001b[0m \u001b[39m# HTTP info\u001b[39;49;00m\n\u001b[1;32m 1241\u001b[0m endpoint\u001b[39m=\u001b[39;49mendpoint,\n\u001b[1;32m 1242\u001b[0m etag_timeout\u001b[39m=\u001b[39;49metag_timeout,\n\u001b[1;32m 1243\u001b[0m headers\u001b[39m=\u001b[39;49mheaders,\n\u001b[1;32m 1244\u001b[0m proxies\u001b[39m=\u001b[39;49mproxies,\n\u001b[1;32m 1245\u001b[0m token\u001b[39m=\u001b[39;49mtoken,\n\u001b[1;32m 1246\u001b[0m \u001b[39m# Additional options\u001b[39;49;00m\n\u001b[1;32m 1247\u001b[0m local_files_only\u001b[39m=\u001b[39;49mlocal_files_only,\n\u001b[1;32m 1248\u001b[0m force_download\u001b[39m=\u001b[39;49mforce_download,\n\u001b[1;32m 1249\u001b[0m )\n",
|
415 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/file_download.py:1295\u001b[0m, in \u001b[0;36m_hf_hub_download_to_cache_dir\u001b[0;34m(cache_dir, repo_id, filename, repo_type, revision, endpoint, etag_timeout, headers, proxies, token, local_files_only, force_download)\u001b[0m\n\u001b[1;32m 1291\u001b[0m \u001b[39mreturn\u001b[39;00m pointer_path\n\u001b[1;32m 1293\u001b[0m \u001b[39m# Try to get metadata (etag, commit_hash, url, size) from the server.\u001b[39;00m\n\u001b[1;32m 1294\u001b[0m \u001b[39m# If we can't, a HEAD request error is returned.\u001b[39;00m\n\u001b[0;32m-> 1295\u001b[0m (url_to_download, etag, commit_hash, expected_size, head_call_error) \u001b[39m=\u001b[39m _get_metadata_or_catch_error(\n\u001b[1;32m 1296\u001b[0m repo_id\u001b[39m=\u001b[39;49mrepo_id,\n\u001b[1;32m 1297\u001b[0m filename\u001b[39m=\u001b[39;49mfilename,\n\u001b[1;32m 1298\u001b[0m repo_type\u001b[39m=\u001b[39;49mrepo_type,\n\u001b[1;32m 1299\u001b[0m revision\u001b[39m=\u001b[39;49mrevision,\n\u001b[1;32m 1300\u001b[0m endpoint\u001b[39m=\u001b[39;49mendpoint,\n\u001b[1;32m 1301\u001b[0m proxies\u001b[39m=\u001b[39;49mproxies,\n\u001b[1;32m 1302\u001b[0m etag_timeout\u001b[39m=\u001b[39;49metag_timeout,\n\u001b[1;32m 1303\u001b[0m headers\u001b[39m=\u001b[39;49mheaders,\n\u001b[1;32m 1304\u001b[0m token\u001b[39m=\u001b[39;49mtoken,\n\u001b[1;32m 1305\u001b[0m local_files_only\u001b[39m=\u001b[39;49mlocal_files_only,\n\u001b[1;32m 1306\u001b[0m storage_folder\u001b[39m=\u001b[39;49mstorage_folder,\n\u001b[1;32m 1307\u001b[0m relative_filename\u001b[39m=\u001b[39;49mrelative_filename,\n\u001b[1;32m 1308\u001b[0m )\n\u001b[1;32m 1310\u001b[0m \u001b[39m# etag can be None for several reasons:\u001b[39;00m\n\u001b[1;32m 1311\u001b[0m \u001b[39m# 1. we passed local_files_only.\u001b[39;00m\n\u001b[1;32m 1312\u001b[0m \u001b[39m# 2. we don't have a connection\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1318\u001b[0m \u001b[39m# If the specified revision is a commit hash, look inside \"snapshots\".\u001b[39;00m\n\u001b[1;32m 1319\u001b[0m \u001b[39m# If the specified revision is a branch or tag, look inside \"refs\".\u001b[39;00m\n\u001b[1;32m 1320\u001b[0m \u001b[39mif\u001b[39;00m head_call_error \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 1321\u001b[0m \u001b[39m# Couldn't make a HEAD call => let's try to find a local file\u001b[39;00m\n",
|
416 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/file_download.py:1746\u001b[0m, in \u001b[0;36m_get_metadata_or_catch_error\u001b[0;34m(repo_id, filename, repo_type, revision, endpoint, proxies, etag_timeout, headers, token, local_files_only, relative_filename, storage_folder)\u001b[0m\n\u001b[1;32m 1744\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m 1745\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m-> 1746\u001b[0m metadata \u001b[39m=\u001b[39m get_hf_file_metadata(\n\u001b[1;32m 1747\u001b[0m url\u001b[39m=\u001b[39;49murl, proxies\u001b[39m=\u001b[39;49mproxies, timeout\u001b[39m=\u001b[39;49metag_timeout, headers\u001b[39m=\u001b[39;49mheaders, token\u001b[39m=\u001b[39;49mtoken\n\u001b[1;32m 1748\u001b[0m )\n\u001b[1;32m 1749\u001b[0m \u001b[39mexcept\u001b[39;00m EntryNotFoundError \u001b[39mas\u001b[39;00m http_error:\n\u001b[1;32m 1750\u001b[0m \u001b[39mif\u001b[39;00m storage_folder \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m relative_filename \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 1751\u001b[0m \u001b[39m# Cache the non-existence of the file\u001b[39;00m\n",
|
417 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114\u001b[0m, in \u001b[0;36mvalidate_hf_hub_args.<locals>._inner_fn\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[39mif\u001b[39;00m check_use_auth_token:\n\u001b[1;32m 112\u001b[0m kwargs \u001b[39m=\u001b[39m smoothly_deprecate_use_auth_token(fn_name\u001b[39m=\u001b[39mfn\u001b[39m.\u001b[39m\u001b[39m__name__\u001b[39m, has_token\u001b[39m=\u001b[39mhas_token, kwargs\u001b[39m=\u001b[39mkwargs)\n\u001b[0;32m--> 114\u001b[0m \u001b[39mreturn\u001b[39;00m fn(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n",
|
418 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/file_download.py:1666\u001b[0m, in \u001b[0;36mget_hf_file_metadata\u001b[0;34m(url, token, proxies, timeout, library_name, library_version, user_agent, headers)\u001b[0m\n\u001b[1;32m 1663\u001b[0m headers[\u001b[39m\"\u001b[39m\u001b[39mAccept-Encoding\u001b[39m\u001b[39m\"\u001b[39m] \u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39midentity\u001b[39m\u001b[39m\"\u001b[39m \u001b[39m# prevent any compression => we want to know the real size of the file\u001b[39;00m\n\u001b[1;32m 1665\u001b[0m \u001b[39m# Retrieve metadata\u001b[39;00m\n\u001b[0;32m-> 1666\u001b[0m r \u001b[39m=\u001b[39m _request_wrapper(\n\u001b[1;32m 1667\u001b[0m method\u001b[39m=\u001b[39;49m\u001b[39m\"\u001b[39;49m\u001b[39mHEAD\u001b[39;49m\u001b[39m\"\u001b[39;49m,\n\u001b[1;32m 1668\u001b[0m url\u001b[39m=\u001b[39;49murl,\n\u001b[1;32m 1669\u001b[0m headers\u001b[39m=\u001b[39;49mheaders,\n\u001b[1;32m 1670\u001b[0m allow_redirects\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m,\n\u001b[1;32m 1671\u001b[0m follow_relative_redirects\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m,\n\u001b[1;32m 1672\u001b[0m proxies\u001b[39m=\u001b[39;49mproxies,\n\u001b[1;32m 1673\u001b[0m timeout\u001b[39m=\u001b[39;49mtimeout,\n\u001b[1;32m 1674\u001b[0m )\n\u001b[1;32m 1675\u001b[0m hf_raise_for_status(r)\n\u001b[1;32m 1677\u001b[0m \u001b[39m# Return\u001b[39;00m\n",
|
419 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/file_download.py:364\u001b[0m, in \u001b[0;36m_request_wrapper\u001b[0;34m(method, url, follow_relative_redirects, **params)\u001b[0m\n\u001b[1;32m 362\u001b[0m \u001b[39m# Recursively follow relative redirects\u001b[39;00m\n\u001b[1;32m 363\u001b[0m \u001b[39mif\u001b[39;00m follow_relative_redirects:\n\u001b[0;32m--> 364\u001b[0m response \u001b[39m=\u001b[39m _request_wrapper(\n\u001b[1;32m 365\u001b[0m method\u001b[39m=\u001b[39;49mmethod,\n\u001b[1;32m 366\u001b[0m url\u001b[39m=\u001b[39;49murl,\n\u001b[1;32m 367\u001b[0m follow_relative_redirects\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m,\n\u001b[1;32m 368\u001b[0m \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mparams,\n\u001b[1;32m 369\u001b[0m )\n\u001b[1;32m 371\u001b[0m \u001b[39m# If redirection, we redirect only relative paths.\u001b[39;00m\n\u001b[1;32m 372\u001b[0m \u001b[39m# This is useful in case of a renamed repository.\u001b[39;00m\n\u001b[1;32m 373\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39m300\u001b[39m \u001b[39m<\u001b[39m\u001b[39m=\u001b[39m response\u001b[39m.\u001b[39mstatus_code \u001b[39m<\u001b[39m\u001b[39m=\u001b[39m \u001b[39m399\u001b[39m:\n",
|
420 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/file_download.py:388\u001b[0m, in \u001b[0;36m_request_wrapper\u001b[0;34m(method, url, follow_relative_redirects, **params)\u001b[0m\n\u001b[1;32m 386\u001b[0m \u001b[39m# Perform request and return if status_code is not in the retry list.\u001b[39;00m\n\u001b[1;32m 387\u001b[0m response \u001b[39m=\u001b[39m get_session()\u001b[39m.\u001b[39mrequest(method\u001b[39m=\u001b[39mmethod, url\u001b[39m=\u001b[39murl, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mparams)\n\u001b[0;32m--> 388\u001b[0m hf_raise_for_status(response)\n\u001b[1;32m 389\u001b[0m \u001b[39mreturn\u001b[39;00m response\n",
|
421 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/site-packages/huggingface_hub/utils/_http.py:417\u001b[0m, in \u001b[0;36mhf_raise_for_status\u001b[0;34m(response, endpoint_name)\u001b[0m\n\u001b[1;32m 415\u001b[0m \u001b[39melif\u001b[39;00m error_code \u001b[39m==\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mEntryNotFound\u001b[39m\u001b[39m\"\u001b[39m:\n\u001b[1;32m 416\u001b[0m message \u001b[39m=\u001b[39m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00mresponse\u001b[39m.\u001b[39mstatus_code\u001b[39m}\u001b[39;00m\u001b[39m Client Error.\u001b[39m\u001b[39m\"\u001b[39m \u001b[39m+\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m\\n\u001b[39;00m\u001b[39m\"\u001b[39m \u001b[39m+\u001b[39m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mEntry Not Found for url: \u001b[39m\u001b[39m{\u001b[39;00mresponse\u001b[39m.\u001b[39murl\u001b[39m}\u001b[39;00m\u001b[39m.\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m--> 417\u001b[0m \u001b[39mraise\u001b[39;00m _format(EntryNotFoundError, message, response) \u001b[39mfrom\u001b[39;00m \u001b[39me\u001b[39;00m\n\u001b[1;32m 419\u001b[0m \u001b[39melif\u001b[39;00m error_code \u001b[39m==\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mGatedRepo\u001b[39m\u001b[39m\"\u001b[39m:\n\u001b[1;32m 420\u001b[0m message \u001b[39m=\u001b[39m (\n\u001b[1;32m 421\u001b[0m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00mresponse\u001b[39m.\u001b[39mstatus_code\u001b[39m}\u001b[39;00m\u001b[39m Client Error.\u001b[39m\u001b[39m\"\u001b[39m \u001b[39m+\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m\\n\u001b[39;00m\u001b[39m\"\u001b[39m \u001b[39m+\u001b[39m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mCannot access gated repo for url \u001b[39m\u001b[39m{\u001b[39;00mresponse\u001b[39m.\u001b[39murl\u001b[39m}\u001b[39;00m\u001b[39m.\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 422\u001b[0m )\n",
|
422 |
+
"\u001b[0;31mEntryNotFoundError\u001b[0m: 404 Client Error. (Request ID: Root=1-676e30f5-6503b00035cc3c54406f318b;5089af88-596d-48a4-9917-100d2a940357)\n\nEntry Not Found for url: https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/model_index.json."
|
423 |
+
]
|
424 |
+
}
|
425 |
+
],
|
426 |
+
"source": [
|
427 |
+
"import tqdm as notebook_tqdm\n",
|
428 |
+
"import gradio as gr\n",
|
429 |
+
"from diffusers import DiffusionPipeline\n",
|
430 |
+
"\n",
|
431 |
+
"# Tải mô hình Diffusion, thay thế 'your_model_name_or_path' bằng tên hoặc đường dẫn mô hình của bạn\n",
|
432 |
+
"pipe = DiffusionPipeline.from_pretrained(\"CompVis/stable-diffusion-v-1-4-original\")\n",
|
433 |
+
"pipe.to('cuda') # Chuyển mô hình sang GPU nếu có\n",
|
434 |
+
"\n",
|
435 |
+
"# Hàm để sinh ảnh từ prompt\n",
|
436 |
+
"def generate(prompt):\n",
|
437 |
+
" return pipe(prompt).images\n",
|
438 |
+
"\n",
|
439 |
+
"# Tạo giao diện Gradio\n",
|
440 |
+
"gr.Interface(\n",
|
441 |
+
" fn=generate,\n",
|
442 |
+
" inputs=gr.Textbox(label=\"Enter your prompt\"), # Nhập mô tả văn bản\n",
|
443 |
+
" outputs=gr.Gallery(label=\"Generated Images\"), # Hiển thị ảnh được tạo ra\n",
|
444 |
+
" live=True # Cập nhật ảnh khi nhập vào mà không cần submit\n",
|
445 |
+
").launch(server_port=9091)\n"
|
446 |
+
]
|
447 |
+
},
|
448 |
+
{
|
449 |
+
"cell_type": "code",
|
450 |
+
"execution_count": 3,
|
451 |
+
"metadata": {},
|
452 |
+
"outputs": [
|
453 |
+
{
|
454 |
+
"name": "stdout",
|
455 |
+
"output_type": "stream",
|
456 |
+
"text": [
|
457 |
+
"Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com\n",
|
458 |
+
"Requirement already satisfied: tqdm in /usr/local/lib/python3.10/site-packages (4.66.5)\n",
|
459 |
+
"\n",
|
460 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
|
461 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
|
462 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
463 |
+
]
|
464 |
+
}
|
465 |
+
],
|
466 |
+
"source": [
|
467 |
+
"pip install tqdm "
|
468 |
+
]
|
469 |
+
},
|
470 |
+
{
|
471 |
+
"cell_type": "code",
|
472 |
+
"execution_count": 25,
|
473 |
+
"metadata": {},
|
474 |
+
"outputs": [
|
475 |
+
{
|
476 |
+
"name": "stdout",
|
477 |
+
"output_type": "stream",
|
478 |
+
"text": [
|
479 |
+
"Collecting nvidia-pyindex\n",
|
480 |
+
" Downloading nvidia-pyindex-1.0.9.tar.gz (10 kB)\n",
|
481 |
+
" Preparing metadata (setup.py) ... \u001b[?25ldone\n",
|
482 |
+
"\u001b[?25hBuilding wheels for collected packages: nvidia-pyindex\n",
|
483 |
+
" Building wheel for nvidia-pyindex (setup.py) ... \u001b[?25ldone\n",
|
484 |
+
"\u001b[?25h Created wheel for nvidia-pyindex: filename=nvidia_pyindex-1.0.9-py3-none-any.whl size=8419 sha256=763ce7ae8d0b44ebae950220f90c4b092eb67d11fac1a125cda310637d42360e\n",
|
485 |
+
" Stored in directory: /home/user/.cache/pip/wheels/05/0a/54/d6d81bbd6c435e7d71c1780ca454a8ae9c655d893225ff1773\n",
|
486 |
+
"Successfully built nvidia-pyindex\n",
|
487 |
+
"Installing collected packages: nvidia-pyindex\n",
|
488 |
+
"Successfully installed nvidia-pyindex-1.0.9\n",
|
489 |
+
"\n",
|
490 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
|
491 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
|
492 |
+
"Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com\n",
|
493 |
+
"Collecting nvidia-ml-py3\n",
|
494 |
+
" Downloading nvidia-ml-py3-7.352.0.tar.gz (19 kB)\n",
|
495 |
+
" Preparing metadata (setup.py) ... \u001b[?25ldone\n",
|
496 |
+
"\u001b[?25hBuilding wheels for collected packages: nvidia-ml-py3\n",
|
497 |
+
" Building wheel for nvidia-ml-py3 (setup.py) ... \u001b[?25ldone\n",
|
498 |
+
"\u001b[?25h Created wheel for nvidia-ml-py3: filename=nvidia_ml_py3-7.352.0-py3-none-any.whl size=19172 sha256=bc7a713099b1ac4e31218a99ea038d245973282ce10b64e73d02383be73a6274\n",
|
499 |
+
" Stored in directory: /tmp/pip-ephem-wheel-cache-zdocri3a/wheels/18/b3/f9/56c61f6b3eeaeb98d060b50f1f75f1857dd1408051090a0533\n",
|
500 |
+
"Successfully built nvidia-ml-py3\n",
|
501 |
+
"Installing collected packages: nvidia-ml-py3\n",
|
502 |
+
"Successfully installed nvidia-ml-py3-7.352.0\n",
|
503 |
+
"\n",
|
504 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
|
505 |
+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n"
|
506 |
+
]
|
507 |
+
}
|
508 |
+
],
|
509 |
+
"source": [
|
510 |
+
"!pip install --upgrade nvidia-pyindex\n",
|
511 |
+
"!pip install --upgrade nvidia-ml-py3\n"
|
512 |
+
]
|
513 |
+
}
|
514 |
+
],
|
515 |
+
"metadata": {
|
516 |
+
"kernelspec": {
|
517 |
+
"display_name": "Python 3",
|
518 |
+
"language": "python",
|
519 |
+
"name": "python3"
|
520 |
+
},
|
521 |
+
"language_info": {
|
522 |
+
"codemirror_mode": {
|
523 |
+
"name": "ipython",
|
524 |
+
"version": 3
|
525 |
+
},
|
526 |
+
"file_extension": ".py",
|
527 |
+
"mimetype": "text/x-python",
|
528 |
+
"name": "python",
|
529 |
+
"nbconvert_exporter": "python",
|
530 |
+
"pygments_lexer": "ipython3",
|
531 |
+
"version": "3.10.13"
|
532 |
+
}
|
533 |
+
},
|
534 |
+
"nbformat": 4,
|
535 |
+
"nbformat_minor": 2
|
536 |
+
}
|
requirements.txt
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
--extra-index-url https://download.pytorch.org/whl/cu121
|
2 |
+
|
3 |
+
torch==2.4.0
|
4 |
+
torchvision==0.19.0
|
5 |
+
pillow==10.4.0
|
6 |
+
imageio==2.36.1
|
7 |
+
imageio-ffmpeg==0.5.1
|
8 |
+
tqdm==4.67.1
|
9 |
+
easydict==1.13
|
10 |
+
opencv-python-headless==4.10.0.84
|
11 |
+
scipy==1.14.1
|
12 |
+
rembg==2.0.60
|
13 |
+
onnxruntime==1.20.1
|
14 |
+
trimesh==4.5.3
|
15 |
+
xatlas==0.0.9
|
16 |
+
pyvista==0.44.2
|
17 |
+
pymeshfix==0.17.0
|
18 |
+
igraph==0.11.8
|
19 |
+
git+https://github.com/EasternJournalist/utils3d.git@9a4eb15e4021b67b12c460c7057d642626897ec8
|
20 |
+
xformers==0.0.27.post2
|
21 |
+
spconv-cu120==2.3.6
|
22 |
+
transformers==4.46.3
|
23 |
+
gradio_litmodel3d==0.0.1
|
24 |
+
https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.0.post2/flash_attn-2.7.0.post2+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
|
25 |
+
https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl?download=true
|
26 |
+
https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/nvdiffrast-0.3.3-cp310-cp310-linux_x86_64.whl?download=true
|