Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,18 +5,14 @@ from fastapi import FastAPI
|
|
| 5 |
from pydantic import BaseModel
|
| 6 |
import uvicorn
|
| 7 |
import threading
|
| 8 |
-
from huggingface_hub import notebook_login
|
| 9 |
-
|
| 10 |
-
# --- 0. Authentification Hugging Face dans le Space ---
|
| 11 |
-
notebook_login() # ouvre une fenêtre pour te connecter si nécessaire
|
| 12 |
|
| 13 |
# --- 1. Charger le modèle ---
|
| 14 |
model_name_or_path = "facebook/MobileLLM-Pro" # modèle gated
|
| 15 |
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_auth_token=True)
|
| 16 |
model = AutoModelForCausalLM.from_pretrained(
|
| 17 |
-
model_name_or_path,
|
| 18 |
-
use_auth_token=True,
|
| 19 |
-
torch_dtype=torch.float16,
|
| 20 |
device_map="auto"
|
| 21 |
)
|
| 22 |
model.eval()
|
|
@@ -37,7 +33,7 @@ def launch_gradio():
|
|
| 37 |
title="MobileLLM-Pro Chat",
|
| 38 |
description="Interface Gradio pour MobileLLM-Pro"
|
| 39 |
)
|
| 40 |
-
iface.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
| 41 |
|
| 42 |
# --- 4. API FastAPI ---
|
| 43 |
app = FastAPI()
|
|
|
|
| 5 |
from pydantic import BaseModel
|
| 6 |
import uvicorn
|
| 7 |
import threading
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# --- 1. Charger le modèle ---
|
| 10 |
model_name_or_path = "facebook/MobileLLM-Pro" # modèle gated
|
| 11 |
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_auth_token=True)
|
| 12 |
model = AutoModelForCausalLM.from_pretrained(
|
| 13 |
+
model_name_or_path,
|
| 14 |
+
use_auth_token=True,
|
| 15 |
+
torch_dtype=torch.float16,
|
| 16 |
device_map="auto"
|
| 17 |
)
|
| 18 |
model.eval()
|
|
|
|
| 33 |
title="MobileLLM-Pro Chat",
|
| 34 |
description="Interface Gradio pour MobileLLM-Pro"
|
| 35 |
)
|
| 36 |
+
iface.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
| 37 |
|
| 38 |
# --- 4. API FastAPI ---
|
| 39 |
app = FastAPI()
|