Spaces:
Sleeping
Sleeping
RatanPrakash
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,21 @@ import dateparser
|
|
11 |
import os
|
12 |
import matplotlib.pyplot as plt
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
# Function to get Instagram post details
|
15 |
import instaloader
|
16 |
def get_instagram_post_details(post_url):
|
@@ -354,6 +369,13 @@ elif app_mode == "Task 1":
|
|
354 |
|
355 |
#############################
|
356 |
#OCR result text to be parsed here through LLM and get product listing content.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
#############################
|
358 |
|
359 |
# Process the OCR result to extract product name and properties
|
|
|
11 |
import os
|
12 |
import matplotlib.pyplot as plt
|
13 |
|
14 |
+
#######Llama3bi integration########
|
15 |
+
import torch
|
16 |
+
from transformers import pipeline
|
17 |
+
model_id = "meta-llama/Llama-3.2-3B-Instruct"
|
18 |
+
pipe = pipeline(
|
19 |
+
"text-generation",
|
20 |
+
model=model_id,
|
21 |
+
torch_dtype=torch.bfloat16,
|
22 |
+
device_map="auto",
|
23 |
+
)
|
24 |
+
messages = [
|
25 |
+
{"role": "system", "content": """Your task is to get the product details out of the text given. The text given will be raw text from OCR of social media images of products,
|
26 |
+
and the goal is to get product details and description so that it can be used for amazon product listing. """},
|
27 |
+
]
|
28 |
+
|
29 |
# Function to get Instagram post details
|
30 |
import instaloader
|
31 |
def get_instagram_post_details(post_url):
|
|
|
369 |
|
370 |
#############################
|
371 |
#OCR result text to be parsed here through LLM and get product listing content.
|
372 |
+
messages.append({"role": "user", "content": ""})
|
373 |
+
outputs = pipe(
|
374 |
+
messages,
|
375 |
+
max_new_tokens=256,
|
376 |
+
)
|
377 |
+
productListingContent = outputs[0]["generated_text"][-1]
|
378 |
+
st.markdown(productListingContent)
|
379 |
#############################
|
380 |
|
381 |
# Process the OCR result to extract product name and properties
|