Spaces:
Configuration error
Configuration error
Fedir Zadniprovskyi
commited on
Commit
·
c0a38da
1
Parent(s):
2afe55d
chore: return the models sorted by the number of downloads
Browse files
faster_whisper_server/main.py
CHANGED
@@ -88,6 +88,8 @@ def health() -> Response:
|
|
88 |
@app.get("/v1/models")
|
89 |
def get_models() -> ModelListResponse:
|
90 |
models = huggingface_hub.list_models(library="ctranslate2", tags="automatic-speech-recognition", cardData=True)
|
|
|
|
|
91 |
transformed_models: list[ModelObject] = []
|
92 |
for model in models:
|
93 |
assert model.created_at is not None
|
@@ -115,11 +117,11 @@ def get_models() -> ModelListResponse:
|
|
115 |
def get_model(
|
116 |
model_name: Annotated[str, Path(example="Systran/faster-distil-whisper-large-v3")],
|
117 |
) -> ModelObject:
|
118 |
-
models =
|
119 |
-
|
120 |
-
model_name=model_name, library="ctranslate2", tags="automatic-speech-recognition", cardData=True
|
121 |
-
)
|
122 |
)
|
|
|
|
|
123 |
if len(models) == 0:
|
124 |
raise HTTPException(status_code=404, detail="Model doesn't exists")
|
125 |
exact_match: ModelInfo | None = None
|
|
|
88 |
@app.get("/v1/models")
|
89 |
def get_models() -> ModelListResponse:
|
90 |
models = huggingface_hub.list_models(library="ctranslate2", tags="automatic-speech-recognition", cardData=True)
|
91 |
+
models = list(models)
|
92 |
+
models.sort(key=lambda model: model.downloads, reverse=True)
|
93 |
transformed_models: list[ModelObject] = []
|
94 |
for model in models:
|
95 |
assert model.created_at is not None
|
|
|
117 |
def get_model(
|
118 |
model_name: Annotated[str, Path(example="Systran/faster-distil-whisper-large-v3")],
|
119 |
) -> ModelObject:
|
120 |
+
models = huggingface_hub.list_models(
|
121 |
+
model_name=model_name, library="ctranslate2", tags="automatic-speech-recognition", cardData=True
|
|
|
|
|
122 |
)
|
123 |
+
models = list(models)
|
124 |
+
models.sort(key=lambda model: model.downloads, reverse=True)
|
125 |
if len(models) == 0:
|
126 |
raise HTTPException(status_code=404, detail="Model doesn't exists")
|
127 |
exact_match: ModelInfo | None = None
|