Spaces:
Sleeping
Sleeping
Maximilian Noichl
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ from pathlib import Path
|
|
| 3 |
import json
|
| 4 |
import base64
|
| 5 |
from datetime import datetime
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# Standard imports
|
| 8 |
import gradio as gr
|
|
@@ -29,10 +31,12 @@ os.environ["GRADIO_ALLOWED_PATHS"] = str(static_dir.resolve())
|
|
| 29 |
|
| 30 |
def process_text(text):
|
| 31 |
"""Example GPU function - in reality, this might be model inference"""
|
|
|
|
|
|
|
| 32 |
return text.upper()
|
| 33 |
|
| 34 |
|
| 35 |
-
@spaces.GPU(duration=60) # Specify GPU duration in seconds
|
| 36 |
def process_and_save(request: gr.Request, text):
|
| 37 |
"""Main processing function that handles tokens and calls GPU function"""
|
| 38 |
# Get and decode the authentication token
|
|
@@ -51,7 +55,8 @@ def process_and_save(request: gr.Request, text):
|
|
| 51 |
with open(file_path, "w") as f:
|
| 52 |
f.write(processed_text)
|
| 53 |
|
| 54 |
-
|
|
|
|
| 55 |
|
| 56 |
# Mark main function as not requiring GPU
|
| 57 |
process_and_save.zerogpu = True
|
|
|
|
| 3 |
import json
|
| 4 |
import base64
|
| 5 |
from datetime import datetime
|
| 6 |
+
import time
|
| 7 |
+
|
| 8 |
|
| 9 |
# Standard imports
|
| 10 |
import gradio as gr
|
|
|
|
| 31 |
|
| 32 |
def process_text(text):
|
| 33 |
"""Example GPU function - in reality, this might be model inference"""
|
| 34 |
+
time.sleep(10)
|
| 35 |
+
|
| 36 |
return text.upper()
|
| 37 |
|
| 38 |
|
| 39 |
+
@spaces.GPU(duration=2*60) # Specify GPU duration in seconds, added for testing
|
| 40 |
def process_and_save(request: gr.Request, text):
|
| 41 |
"""Main processing function that handles tokens and calls GPU function"""
|
| 42 |
# Get and decode the authentication token
|
|
|
|
| 55 |
with open(file_path, "w") as f:
|
| 56 |
f.write(processed_text)
|
| 57 |
|
| 58 |
+
# Convert file_path to a string before returning
|
| 59 |
+
return gr.File(value=str(file_path))
|
| 60 |
|
| 61 |
# Mark main function as not requiring GPU
|
| 62 |
process_and_save.zerogpu = True
|