Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -104,7 +104,8 @@ css = """
|
|
104 |
footer {visibility: hidden}
|
105 |
"""
|
106 |
|
107 |
-
|
|
|
108 |
gr.Markdown("# 🌟 NSFW 图片分类器")
|
109 |
gr.Markdown(description)
|
110 |
|
@@ -124,8 +125,8 @@ with gr.Blocks(theme="huggingface", css=css) as demo:
|
|
124 |
|
125 |
submit_btn.click(predict, inputs=image_input, outputs=output_label)
|
126 |
|
127 |
-
#
|
128 |
-
|
129 |
|
130 |
# 启动 Web 界面
|
131 |
demo.launch()
|
|
|
104 |
footer {visibility: hidden}
|
105 |
"""
|
106 |
|
107 |
+
# 使用 Blocks API 创建界面
|
108 |
+
with gr.Blocks(css=css) as demo:
|
109 |
gr.Markdown("# 🌟 NSFW 图片分类器")
|
110 |
gr.Markdown(description)
|
111 |
|
|
|
125 |
|
126 |
submit_btn.click(predict, inputs=image_input, outputs=output_label)
|
127 |
|
128 |
+
# 手动为 API 设置路由
|
129 |
+
demo.add_api_route("/api/predict", api_predict, methods=["POST"])
|
130 |
|
131 |
# 启动 Web 界面
|
132 |
demo.launch()
|