wli1995 commited on
Commit
fd40704
·
verified ·
1 Parent(s): a021116

Update gradio demo

Browse files
README.md CHANGED
@@ -111,10 +111,13 @@ $ python gradio_demo.py
111
  [INFO] SOC Name: AX650N
112
  [INFO] VNPU type: VNPUType.DISABLED
113
  [INFO] Compiler version: 4.2 6bff2f67
114
- * Running on local URL: http://0.0.0.0:7860
115
- * To create a public link, set `share=True` in `launch()`.
116
- ```
117
- Then use the M.2 Accelerator card IP instead of the 0.0.0.0, and use chrome open the URL: http://[your ip]:7860
 
 
 
118
 
119
  ![gradio_demo](./assert/gradio_demo.jpg)
120
 
 
111
  [INFO] SOC Name: AX650N
112
  [INFO] VNPU type: VNPUType.DISABLED
113
  [INFO] Compiler version: 4.2 6bff2f67
114
+ ==================================================
115
+ 🌐 SuperResolution 超分辨率 Web UI 已启动!
116
+ 🔗 本地访问: http://127.0.0.1:7860
117
+ 🔗 局域网访问: http://10.126.33.124:7860
118
+ ==================================================
119
+
120
+ Then open the link in the browser to use the web UI:
121
 
122
  ![gradio_demo](./assert/gradio_demo.jpg)
123
 
python/__pycache__/common.cpython-313.pyc CHANGED
Binary files a/python/__pycache__/common.cpython-313.pyc and b/python/__pycache__/common.cpython-313.pyc differ
 
python/__pycache__/common.cpython-314.pyc ADDED
Binary file (4.67 kB). View file
 
python/__pycache__/imgproc.cpython-313.pyc CHANGED
Binary files a/python/__pycache__/imgproc.cpython-313.pyc and b/python/__pycache__/imgproc.cpython-313.pyc differ
 
python/gradio_demo.py CHANGED
@@ -7,6 +7,7 @@ import time
7
  import axengine as axe
8
  import common
9
  import imgproc
 
10
 
11
  rgb_range=255
12
  scale=2
@@ -227,7 +228,7 @@ def show_sr():
227
  # ======================
228
  # Gradio UI
229
  # ======================
230
- with gr.Blocks(title="超分辨率可视化工具", theme=gr.themes.Soft()) as demo:
231
  gr.Markdown("## 🚀 超分辨率模型效果可视化")
232
  gr.Markdown("上传图片或视频,选择模型,点击箭头切换原图/超分图!")
233
 
@@ -321,6 +322,39 @@ with gr.Blocks(title="超分辨率可视化工具", theme=gr.themes.Soft()) as d
321
  download_video
322
  ]
323
  )
 
 
 
 
 
 
 
 
 
 
 
 
324
 
325
  if __name__ == "__main__":
326
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  import axengine as axe
8
  import common
9
  import imgproc
10
+ import socket
11
 
12
  rgb_range=255
13
  scale=2
 
228
  # ======================
229
  # Gradio UI
230
  # ======================
231
+ with gr.Blocks(title="超分辨率可视化工具") as demo:
232
  gr.Markdown("## 🚀 超分辨率模型效果可视化")
233
  gr.Markdown("上传图片或视频,选择模型,点击箭头切换原图/超分图!")
234
 
 
322
  download_video
323
  ]
324
  )
325
+ def get_local_ip():
326
+ """获取本机局域网IP地址"""
327
+ try:
328
+ # 创建一个UDP连接(不会真正发送数据)
329
+ with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
330
+ s.connect(("8.8.8.8", 80)) # 连接到公共DNS(Google)
331
+ ip = s.getsockname()[0]
332
+ return ip
333
+ except Exception:
334
+ # 回退到 localhost
335
+ return "127.0.0.1"
336
+
337
 
338
  if __name__ == "__main__":
339
+ # demo.launch(server_name="0.0.0.0", server_port=7860, theme=gr.themes.Soft())
340
+
341
+ server_port = 7860
342
+ server_name = "0.0.0.0"
343
+
344
+ # 获取本机IP
345
+ local_ip = get_local_ip()
346
+
347
+ # 打印可点击的URL(大多数终端支持点击)
348
+ print("\n" + "="*50)
349
+ print("🌐 SuperResolution 超分辨率 Web UI 已启动!")
350
+ print(f"🔗 本地访问: http://127.0.0.1:{server_port}")
351
+ if local_ip != "127.0.0.1":
352
+ print(f"🔗 局域网访问: http://{local_ip}:{server_port}")
353
+ print("="*50 + "\n")
354
+
355
+ # 启动Gradio应用
356
+ demo.launch(
357
+ server_name=server_name,
358
+ server_port=server_port,
359
+ theme=gr.themes.Soft()
360
+ )