Spaces:
Sleeping
Sleeping
Hjgugugjhuhjggg
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -3,8 +3,8 @@ 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
|
@@ -99,7 +99,7 @@ class S3ModelLoader:
|
|
99 |
def download_model_from_huggingface(self, model_name):
|
100 |
try:
|
101 |
logging.info(f"Downloading model {model_name} from Hugging Face...")
|
102 |
-
model_dir = hf_hub_download(model_name, token=HUGGINGFACE_HUB_TOKEN)
|
103 |
self.s3_client.upload_file(model_dir, self.bucket_name, f"lilmeaty_garca/{model_name}")
|
104 |
logging.info(f"Model {model_name} saved to S3 successfully.")
|
105 |
except Exception as e:
|
|
|
3 |
import threading
|
4 |
import boto3
|
5 |
import torch
|
6 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig, StoppingCriteriaList, AutoConfig
|
7 |
+
from fastapi import FastAPI, HTTPException, Request
|
8 |
from pydantic import BaseModel, field_validator
|
9 |
from io import BytesIO
|
10 |
from huggingface_hub import hf_hub_download
|
|
|
99 |
def download_model_from_huggingface(self, model_name):
|
100 |
try:
|
101 |
logging.info(f"Downloading model {model_name} from Hugging Face...")
|
102 |
+
model_dir = hf_hub_download(model_name, token=HUGGINGFACE_HUB_TOKEN, filename=model_name.split("/")[-1])
|
103 |
self.s3_client.upload_file(model_dir, self.bucket_name, f"lilmeaty_garca/{model_name}")
|
104 |
logging.info(f"Model {model_name} saved to S3 successfully.")
|
105 |
except Exception as e:
|