Spaces:
Sleeping
Sleeping
Update main.py
Browse files7 unmodified lines89101112131457 unmodified lines727374757677787980818283848586878812 unmodified lines1011021031041051061071087 unmodified linesimport shutilimport osimport iofrom transformers import pipeline, CLIPProcessor, CLIPModelfrom datetime import datetimeimport uvicorn# Hugging Face GPT or LLM model for content-based name generation57 unmodified linestext += para.textreturn text# Function to extract text from imagesdef extract_text_from_image(image_path):image = Image.open(image_path)return pytesseract.image_to_string(image)# Function to extract image featuresdef extract_features_from_image(image_path):image = Image.open(image_path)inputs = clip_processor(images=image, return_tensors="pt")outputs = clip_model.get_image_features(**inputs)return outputs# Function to process filesdef process_files(files, industry):12 unmodified linestext = extract_text_from_pdf(file_path)elif filename.endswith('.docx'):text = extract_text_from_docx(file_path)elif filename.endswith(('png', 'jpg', 'jpeg')):text = extract_text_from_image(file_path)# Generate name based on LLM and include timestamp for uniquenesscontent_name = generate_name_based_on_content(text,industry) if text else 'Untitled'7 unmodified lines891011121357 unmodified lines71727374757612 unmodified lines89909192939495967 unmodified linesimport shutilimport osimport iofrom datetime import datetimeimport uvicorn# Hugging Face GPT or LLM model for content-based name generation57 unmodified linestext += para.textreturn text# Function to process filesdef process_files(files, industry):12 unmodified linestext = extract_text_from_pdf(file_path)elif filename.endswith('.docx'):text = extract_text_from_docx(file_path)else:print("Invalid")# Generate name based on LLM and include timestamp for uniquenesscontent_name = generate_name_based_on_content(text,industry) if text else 'Untitled'
main.py+2-14