Commit
·
d9c331d
1
Parent(s):
3daafa3
add fastapi
Browse files
main.py
CHANGED
@@ -1,6 +1,13 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
def generate_image(prompt, negative_prompt, seed, guidance_scale, num_inference_steps):
|
5 |
return torch.rand(512, 512, 3)
|
6 |
|
@@ -112,4 +119,8 @@ with gr.Blocks(css=css) as demo:
|
|
112 |
outputs = [result]
|
113 |
)
|
114 |
|
115 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
|
5 |
+
app = FastAPI()
|
6 |
+
|
7 |
+
@app.get("/")
|
8 |
+
def read_root():
|
9 |
+
return {"Hello": "World"}
|
10 |
+
|
11 |
def generate_image(prompt, negative_prompt, seed, guidance_scale, num_inference_steps):
|
12 |
return torch.rand(512, 512, 3)
|
13 |
|
|
|
119 |
outputs = [result]
|
120 |
)
|
121 |
|
122 |
+
app = gr.mount_gradio_app(app, demo, "/demo")
|
123 |
+
|
124 |
+
if __name__ == "__main__":
|
125 |
+
import uvicorn
|
126 |
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|