Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,9 +15,9 @@ def load_model():
|
|
| 15 |
try:
|
| 16 |
print("Loading model from safetensors format...")
|
| 17 |
|
| 18 |
-
# Load tokenizer and model from
|
| 19 |
-
tokenizer = AutoTokenizer.from_pretrained("
|
| 20 |
-
model = AutoModelForSeq2SeqLM.from_pretrained("
|
| 21 |
|
| 22 |
print("✓ Model and tokenizer loaded successfully")
|
| 23 |
print(f" Model parameters: {model.num_parameters():,}")
|
|
@@ -35,7 +35,8 @@ def load_model():
|
|
| 35 |
|
| 36 |
except Exception as e:
|
| 37 |
print(f"❌ Error loading model: {e}")
|
| 38 |
-
print("Make sure the model files (model.safetensors, config.json, tokenizer.json) are in the
|
|
|
|
| 39 |
return None
|
| 40 |
|
| 41 |
# Load model at startup
|
|
@@ -57,7 +58,7 @@ def summarize_text(
|
|
| 57 |
Summarize the input text with customizable parameters
|
| 58 |
"""
|
| 59 |
if summarizer is None:
|
| 60 |
-
return "❌ Error: Model not loaded. Please check model files in
|
| 61 |
|
| 62 |
if not text.strip():
|
| 63 |
return "⚠️ Please enter some text to summarize."
|
|
|
|
| 15 |
try:
|
| 16 |
print("Loading model from safetensors format...")
|
| 17 |
|
| 18 |
+
# Load tokenizer and model from current directory (root of Space)
|
| 19 |
+
tokenizer = AutoTokenizer.from_pretrained(".")
|
| 20 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(".")
|
| 21 |
|
| 22 |
print("✓ Model and tokenizer loaded successfully")
|
| 23 |
print(f" Model parameters: {model.num_parameters():,}")
|
|
|
|
| 35 |
|
| 36 |
except Exception as e:
|
| 37 |
print(f"❌ Error loading model: {e}")
|
| 38 |
+
print("Make sure the model files (model.safetensors, config.json, tokenizer.json) are in the root directory")
|
| 39 |
+
print(f"Current directory contents: {os.listdir('.')}")
|
| 40 |
return None
|
| 41 |
|
| 42 |
# Load model at startup
|
|
|
|
| 58 |
Summarize the input text with customizable parameters
|
| 59 |
"""
|
| 60 |
if summarizer is None:
|
| 61 |
+
return "❌ Error: Model not loaded. Please check model files (model.safetensors, config.json, tokenizer.json) in the root directory."
|
| 62 |
|
| 63 |
if not text.strip():
|
| 64 |
return "⚠️ Please enter some text to summarize."
|