Spaces:
Running
Running
Commit ·
06611cb
1
Parent(s): 249049b
Load model from HF Hub
Browse filesFiles changed (3)
- Dockerfile+5-11
- app.py+20-3
- requirements.txt+4-1
12345678910111213141516# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker# you will also find guides on how best to write your DockerfileFROM python:3.9RUN useradd -m -u 1000 userUSER userENV PATH="/home/user/.local/bin:$PATH"WORKDIR /appCOPY --chown=user ./requirements.txt requirements.txtRUN pip install --no-cache-dir --upgrade -r requirements.txtCOPY --chown=user . /appCMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]12345678910FROM python:3.10-slimWORKDIR /appCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txtCOPY . .CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
1234567from fastapi import FastAPIapp = FastAPI()@app.get("/")def greet_json():return {"Hello": "World!"}123456789101112131415161718192021222324from fastapi import FastAPIimport torchimport picklefrom huggingface_hub import hf_hub_downloadapp = FastAPI()# Download files from model repotag_vocab_path = hf_hub_download(repo_id="SinaLab/Nested",filename="tag_vocab.pkl")checkpoint_path = hf_hub_download(repo_id="SinaLab/Nested",filename="checkpoints/checkpoint_2.pt")# Load modelwith open(tag_vocab_path, "rb") as f:id2label = pickle.load(f)model = torch.load(checkpoint_path, map_location="cpu")model.eval()
12fastapiuvicorn[standard]12345torchfastapiuvicornnumpyhuggingface_hub
Dockerfile+5-11
app.py+20-3
requirements.txt+4-1