Commit
·
8b8d633
1
Parent(s):
f6283a6
Update Gradio launch settings to enable API endpoint with name "predict" while simplifying the configuration for both local and Spaces environments, enhancing usability and performance.
Browse files
app.py
CHANGED
@@ -268,25 +268,15 @@ with gr.Blocks(
|
|
268 |
# Launch with Spaces-specific settings
|
269 |
if __name__ == "__main__":
|
270 |
import os
|
271 |
-
from spaces.zero.gradio import launch # Use Spaces specific launch function
|
272 |
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
)
|
285 |
-
else: # Local development
|
286 |
-
demo.launch(
|
287 |
-
server_name="0.0.0.0",
|
288 |
-
server_port=7860,
|
289 |
-
show_error=True,
|
290 |
-
share=True, # Only use share=True for local development
|
291 |
-
api_name=None # Disable API endpoint
|
292 |
-
)
|
|
|
268 |
# Launch with Spaces-specific settings
|
269 |
if __name__ == "__main__":
|
270 |
import os
|
|
|
271 |
|
272 |
+
# Use standard Gradio launch with API enabled
|
273 |
+
demo.launch(
|
274 |
+
server_name="0.0.0.0",
|
275 |
+
server_port=7860,
|
276 |
+
show_error=True,
|
277 |
+
enable_queue=True,
|
278 |
+
max_threads=1,
|
279 |
+
api_name="predict", # Enable API endpoint with name "predict"
|
280 |
+
share=False, # Don't use share on Spaces
|
281 |
+
prevent_thread_lock=True # Prevent thread lock issues
|
282 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|