pdarleyjr commited on
Commit
0b1bc54
·
1 Parent(s): 015c1ba

Simplify server configuration and update task log

Browse files
Files changed (1) hide show
  1. app.py +10 -24
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
- # Mount Gradio app to FastAPI
65
- app = gr.mount_gradio_app(app, demo, path="/")
66
-
67
- # Launch the app with FastAPI integration
68
  if __name__ == "__main__":
69
- import uvicorn
70
- demo.queue(max_size=20)
71
- uvicorn.run(
72
- app,
73
- host="0.0.0.0",
74
- port=7860,
75
- log_level="info"
 
 
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
  )