File size: 859 Bytes
ce1dd07
 
370c710
dfcd6b0
 
6a05099
 
 
 
 
dfcd6b0
 
ce1dd07
cb76ab3
 
ce1dd07
 
 
 
 
 
 
 
 
278270a
cb76ab3
ce1dd07
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from routers import training
from huggingface_hub import login
from config import settings
import torch
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", revision="fp16", torch_dtype=torch.float16)


login(settings.huggingface_key)

# app = FastAPI(openapi_url="/api/v1/sparrow-ml/openapi.json", docs_url="/api/v1/sparrow-ml/docs")
app = FastAPI()

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_methods=["*"],
    allow_headers=["*"],
    allow_credentials=True,
)

# app.include_router(inference.router, prefix="/api-inference/v1/sparrow-ml", tags=["Inference"])
app.include_router(training.router)


@app.get("/")
async def root():
    return {"message": "Sparrow ML API"}