Spaces:
Running
on
Zero
Running
on
Zero
gpu wrapped greetwrappper
Browse files
app.py
CHANGED
|
@@ -45,6 +45,13 @@ def greet(request: gr.Request, n):
|
|
| 45 |
except Exception as e:
|
| 46 |
return {"error": str(e)}
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# Build a simple Gradio Blocks interface that also shows a static HTML iframe
|
| 50 |
with gr.Blocks() as demo:
|
|
@@ -58,7 +65,7 @@ with gr.Blocks() as demo:
|
|
| 58 |
|
| 59 |
# Add the original demonstration interface
|
| 60 |
# (just a numeric input feeding into the greet() function)
|
| 61 |
-
greet_interface = gr.Interface(fn=
|
| 62 |
greet_interface.render()
|
| 63 |
|
| 64 |
|
|
|
|
| 45 |
except Exception as e:
|
| 46 |
return {"error": str(e)}
|
| 47 |
|
| 48 |
+
@spaces.GPU(duration=4*60) # Not possible with IP-based quotas on certain Spaces
|
| 49 |
+
def greet_wrapper(request: gr.Request, n):
|
| 50 |
+
"""
|
| 51 |
+
Simple wrapper function that passes through inputs to greet function
|
| 52 |
+
"""
|
| 53 |
+
return greet(request, n)
|
| 54 |
+
|
| 55 |
|
| 56 |
# Build a simple Gradio Blocks interface that also shows a static HTML iframe
|
| 57 |
with gr.Blocks() as demo:
|
|
|
|
| 65 |
|
| 66 |
# Add the original demonstration interface
|
| 67 |
# (just a numeric input feeding into the greet() function)
|
| 68 |
+
greet_interface = gr.Interface(fn=greet_wrapper, inputs=gr.Number(), outputs=gr.JSON())
|
| 69 |
greet_interface.render()
|
| 70 |
|
| 71 |
|