Spaces:
Running
Running
Update caption_app.py
Browse files- caption_app.py +4 -3
caption_app.py
CHANGED
|
@@ -16,9 +16,10 @@ app = FastAPI()
|
|
| 16 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 17 |
templates = Jinja2Templates(directory="templates")
|
| 18 |
|
| 19 |
-
# Load BLIP model and processor
|
| 20 |
-
|
| 21 |
-
|
|
|
|
| 22 |
|
| 23 |
@app.get("/", response_class=HTMLResponse)
|
| 24 |
async def main(request: Request):
|
|
|
|
| 16 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 17 |
templates = Jinja2Templates(directory="templates")
|
| 18 |
|
| 19 |
+
# Load BLIP model and processor with local caching
|
| 20 |
+
cache_dir = "./model_cache"
|
| 21 |
+
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base", cache_dir=cache_dir)
|
| 22 |
+
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base", cache_dir=cache_dir)
|
| 23 |
|
| 24 |
@app.get("/", response_class=HTMLResponse)
|
| 25 |
async def main(request: Request):
|