Update app.py
Browse files
app.py
CHANGED
|
@@ -3,12 +3,18 @@ from gradio_client import Client
|
|
| 3 |
import spaces
|
| 4 |
|
| 5 |
def text_to_image(prompt):
|
|
|
|
|
|
|
|
|
|
| 6 |
client = Client("hysts/SDXL")
|
| 7 |
img = client.predict(prompt, api_name="/predict")
|
| 8 |
return img
|
| 9 |
|
| 10 |
@spaces.GPU
|
| 11 |
def generate(prompt):
|
|
|
|
|
|
|
|
|
|
| 12 |
return text_to_image(prompt)
|
| 13 |
|
| 14 |
with gr.Blocks() as demo:
|
|
|
|
| 3 |
import spaces
|
| 4 |
|
| 5 |
def text_to_image(prompt):
|
| 6 |
+
from gradio.context import LocalContext
|
| 7 |
+
request = LocalContext.request.get(None)
|
| 8 |
+
print(f"Request available in text_to_image: {request is not None} {request}")
|
| 9 |
client = Client("hysts/SDXL")
|
| 10 |
img = client.predict(prompt, api_name="/predict")
|
| 11 |
return img
|
| 12 |
|
| 13 |
@spaces.GPU
|
| 14 |
def generate(prompt):
|
| 15 |
+
from gradio.context import LocalContext
|
| 16 |
+
request = LocalContext.request.get(None)
|
| 17 |
+
print(f"Request available in generate: {request is not None} {request}")
|
| 18 |
return text_to_image(prompt)
|
| 19 |
|
| 20 |
with gr.Blocks() as demo:
|