Simplify server configuration and update task log
Browse files
app.py
CHANGED
@@ -1,18 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
3 |
-
from fastapi import FastAPI
|
4 |
-
from fastapi.middleware.cors import CORSMiddleware
|
5 |
-
|
6 |
-
app = FastAPI()
|
7 |
-
|
8 |
-
# Configure CORS
|
9 |
-
app.add_middleware(
|
10 |
-
CORSMiddleware,
|
11 |
-
allow_origins=["https://pdarleyjr.github.io"],
|
12 |
-
allow_credentials=True,
|
13 |
-
allow_methods=["*"],
|
14 |
-
allow_headers=["*"],
|
15 |
-
)
|
16 |
|
17 |
# Load the base T5 model and tokenizer
|
18 |
model = T5ForConditionalGeneration.from_pretrained('t5-small')
|
@@ -61,16 +48,15 @@ demo = gr.Interface(
|
|
61 |
allow_flagging="never"
|
62 |
)
|
63 |
|
64 |
-
#
|
65 |
-
app = gr.mount_gradio_app(app, demo, path="/")
|
66 |
-
|
67 |
-
# Launch the app with FastAPI integration
|
68 |
if __name__ == "__main__":
|
69 |
-
|
70 |
-
demo.
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
76 |
)
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# Load the base T5 model and tokenizer
|
5 |
model = T5ForConditionalGeneration.from_pretrained('t5-small')
|
|
|
48 |
allow_flagging="never"
|
49 |
)
|
50 |
|
51 |
+
# Launch the app
|
|
|
|
|
|
|
52 |
if __name__ == "__main__":
|
53 |
+
demo.queue(concurrency_count=1) # Single request at a time for stability
|
54 |
+
demo.launch(
|
55 |
+
server_name="0.0.0.0",
|
56 |
+
server_port=7860,
|
57 |
+
share=False,
|
58 |
+
root_path="",
|
59 |
+
show_api=True,
|
60 |
+
allowed_paths=None, # Allow all paths
|
61 |
+
quiet=True # Reduce logging noise
|
62 |
)
|