Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,18 +8,12 @@ from langchain.text_splitter import RecursiveCharacterTextSplitter
|
|
| 8 |
from langchain_community.vectorstores import FAISS
|
| 9 |
from langchain.chains import ConversationalRetrievalChain
|
| 10 |
from langchain.memory import ConversationBufferMemory
|
| 11 |
-
from langchain_community.llms import HuggingFaceEndpoint
|
| 12 |
-
from langchain_huggingface import HuggingFaceEmbeddings
|
| 13 |
import torch
|
| 14 |
from PIL import Image
|
| 15 |
-
from torchvision import transforms
|
| 16 |
-
from torchvision.models import resnet50, ResNet50_Weights
|
| 17 |
from torchvision import transforms, models
|
| 18 |
|
| 19 |
-
|
| 20 |
class GeometryImageClassifier:
|
| 21 |
def __init__(self):
|
| 22 |
-
# Use ResNet18 instead of ResNet50 - lighter and pre-downloaded
|
| 23 |
self.model = models.resnet18(pretrained=True)
|
| 24 |
self.model.fc = torch.nn.Identity()
|
| 25 |
self.model = self.model.to('cpu')
|
|
@@ -83,7 +77,6 @@ class GeometryImageClassifier:
|
|
| 83 |
# ✅ Use a strong sentence embedding model
|
| 84 |
semantic_model = SentenceTransformer("all-MiniLM-L6-v2")
|
| 85 |
|
| 86 |
-
|
| 87 |
def extract_text_from_docx(file_path):
|
| 88 |
""" ✅ Extracts normal text & tables from a .docx file for better retrieval. """
|
| 89 |
doc = docx.Document(file_path)
|
|
|
|
| 8 |
from langchain_community.vectorstores import FAISS
|
| 9 |
from langchain.chains import ConversationalRetrievalChain
|
| 10 |
from langchain.memory import ConversationBufferMemory
|
|
|
|
|
|
|
| 11 |
import torch
|
| 12 |
from PIL import Image
|
|
|
|
|
|
|
| 13 |
from torchvision import transforms, models
|
| 14 |
|
|
|
|
| 15 |
class GeometryImageClassifier:
|
| 16 |
def __init__(self):
|
|
|
|
| 17 |
self.model = models.resnet18(pretrained=True)
|
| 18 |
self.model.fc = torch.nn.Identity()
|
| 19 |
self.model = self.model.to('cpu')
|
|
|
|
| 77 |
# ✅ Use a strong sentence embedding model
|
| 78 |
semantic_model = SentenceTransformer("all-MiniLM-L6-v2")
|
| 79 |
|
|
|
|
| 80 |
def extract_text_from_docx(file_path):
|
| 81 |
""" ✅ Extracts normal text & tables from a .docx file for better retrieval. """
|
| 82 |
doc = docx.Document(file_path)
|