Spaces:
Running
Running
Uploading FoodExtract demo app.py
Browse files
app.py
CHANGED
|
@@ -29,23 +29,34 @@ def pred_on_text(input_text):
|
|
| 29 |
# Note: You may have to replace my username `objects76` for your own
|
| 30 |
MODEL_PATH = "objects76/FoodExtract-gemma-3-270m-fine-tune-v1"
|
| 31 |
|
| 32 |
-
# Load the model into a pipeline
|
| 33 |
-
loaded_model = AutoModelForCausalLM.from_pretrained(
|
| 34 |
-
pretrained_model_name_or_path=MODEL_PATH,
|
| 35 |
-
dtype="auto",
|
| 36 |
-
device_map="auto",
|
| 37 |
-
attn_implementation="eager"
|
| 38 |
-
)
|
| 39 |
|
| 40 |
# Load the tokenizer
|
| 41 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 42 |
MODEL_PATH
|
| 43 |
)
|
| 44 |
|
| 45 |
-
#
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
# Create the demo
|
| 51 |
description = """Extract food and drink items from text with a fine-tuned SLM (Small Language Model) or more specifically a fine-tuned [Gemma 3 270M](https://huggingface.co/google/gemma-3-270m-it).
|
|
|
|
| 29 |
# Note: You may have to replace my username `objects76` for your own
|
| 30 |
MODEL_PATH = "objects76/FoodExtract-gemma-3-270m-fine-tune-v1"
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# Load the tokenizer
|
| 34 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 35 |
MODEL_PATH
|
| 36 |
)
|
| 37 |
|
| 38 |
+
# # Load the model into a pipeline
|
| 39 |
+
# loaded_model = AutoModelForCausalLM.from_pretrained(
|
| 40 |
+
# pretrained_model_name_or_path=MODEL_PATH,
|
| 41 |
+
# dtype="auto",
|
| 42 |
+
# device_map="auto",
|
| 43 |
+
# attn_implementation="eager"
|
| 44 |
+
# )
|
| 45 |
+
#
|
| 46 |
+
# # Create model pipeline
|
| 47 |
+
# loaded_model_pipeline = pipeline("text-generation",
|
| 48 |
+
# model=loaded_model,
|
| 49 |
+
# tokenizer=tokenizer)
|
| 50 |
+
|
| 51 |
+
loaded_model_pipeline = pipeline(
|
| 52 |
+
"text-generation",
|
| 53 |
+
model=MODEL_PATH, # ← pass path, let pipeline load
|
| 54 |
+
tokenizer=tokenizer,
|
| 55 |
+
torch_dtype="auto",
|
| 56 |
+
device_map="auto",
|
| 57 |
+
model_kwargs={"attn_implementation": "eager"}
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
|
| 61 |
# Create the demo
|
| 62 |
description = """Extract food and drink items from text with a fine-tuned SLM (Small Language Model) or more specifically a fine-tuned [Gemma 3 270M](https://huggingface.co/google/gemma-3-270m-it).
|