Spaces:
Sleeping
Sleeping
Hjgugugjhuhjggg
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,18 @@
|
|
1 |
import os
|
2 |
import logging
|
3 |
-
import time
|
4 |
import threading
|
5 |
-
import asyncio
|
6 |
-
import torch
|
7 |
import boto3
|
8 |
-
import
|
9 |
-
from
|
10 |
-
from fastapi
|
11 |
from pydantic import BaseModel, field_validator
|
12 |
-
from
|
13 |
-
AutoConfig,
|
14 |
-
AutoModelForCausalLM,
|
15 |
-
AutoTokenizer,
|
16 |
-
GenerationConfig,
|
17 |
-
StoppingCriteriaList,
|
18 |
-
pipeline
|
19 |
-
)
|
20 |
from huggingface_hub import hf_hub_download
|
21 |
-
import uvicorn
|
22 |
import requests
|
23 |
-
|
24 |
-
import numpy as np
|
25 |
import soundfile as sf
|
|
|
|
|
26 |
|
27 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(filename)s:%(lineno)d - %(message)s")
|
28 |
|
@@ -224,6 +214,3 @@ async def generate(request: Request, body: GenerateRequest):
|
|
224 |
except Exception as e:
|
225 |
logging.exception(f"An unexpected error occurred: {e}")
|
226 |
raise HTTPException(status_code=500, detail="An unexpected error occurred.")
|
227 |
-
|
228 |
-
if __name__ == "__main__":
|
229 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
1 |
import os
|
2 |
import logging
|
|
|
3 |
import threading
|
|
|
|
|
4 |
import boto3
|
5 |
+
import torch
|
6 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig, StoppingCriteriaList
|
7 |
+
from fastapi import FastAPI, HTTPException
|
8 |
from pydantic import BaseModel, field_validator
|
9 |
+
from io import BytesIO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
from huggingface_hub import hf_hub_download
|
|
|
11 |
import requests
|
12 |
+
import asyncio
|
|
|
13 |
import soundfile as sf
|
14 |
+
import numpy as np
|
15 |
+
from fastapi.responses import StreamingResponse, Response
|
16 |
|
17 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(filename)s:%(lineno)d - %(message)s")
|
18 |
|
|
|
214 |
except Exception as e:
|
215 |
logging.exception(f"An unexpected error occurred: {e}")
|
216 |
raise HTTPException(status_code=500, detail="An unexpected error occurred.")
|
|
|
|
|
|