Spaces:
Running
Running
GitHub Actions commited on
Commit ·
88759fa
1
Parent(s): 0d50c35
Sync from GitHub Actions
Browse files
visual_product_search/logger/__init__.py
CHANGED
|
@@ -2,7 +2,7 @@ import logging
|
|
| 2 |
import os
|
| 3 |
from datetime import datetime
|
| 4 |
|
| 5 |
-
dir = 'tmp/logs'
|
| 6 |
os.makedirs(dir, exist_ok=True)
|
| 7 |
|
| 8 |
LOG_FILE = f"{datetime.now().strftime('%m_%d_%Y_%H_%M_%S')}.log"
|
|
|
|
| 2 |
import os
|
| 3 |
from datetime import datetime
|
| 4 |
|
| 5 |
+
dir = '/tmp/logs'
|
| 6 |
os.makedirs(dir, exist_ok=True)
|
| 7 |
|
| 8 |
LOG_FILE = f"{datetime.now().strftime('%m_%d_%Y_%H_%M_%S')}.log"
|
visual_product_search/pipeline/prediction_pipeline.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import sys
|
| 2 |
import environ
|
| 3 |
from pathlib import Path
|
|
|
|
| 4 |
from pymilvus import connections
|
| 5 |
|
| 6 |
from visual_product_search.embeddings.embed import get_image_embedding, get_text_embedding
|
|
@@ -17,15 +18,20 @@ class ProductPredictionPipeline:
|
|
| 17 |
_Database = None
|
| 18 |
def __init__(self, config_path="config/model.yaml"):
|
| 19 |
try:
|
| 20 |
-
self.env = environ.Env()
|
| 21 |
-
environ.Env.read_env(Path(__file__).resolve().parent.parent / ".env")
|
| 22 |
self.config = load_config(config_path)
|
| 23 |
|
| 24 |
-
connections.connect(alias="default",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
if ProductPredictionPipeline._Database is None:
|
| 27 |
ProductPredictionPipeline._Database = DatabaseSearch(
|
| 28 |
-
collection_name=
|
| 29 |
)
|
| 30 |
|
| 31 |
except Exception as e:
|
|
|
|
| 1 |
import sys
|
| 2 |
import environ
|
| 3 |
from pathlib import Path
|
| 4 |
+
import os
|
| 5 |
from pymilvus import connections
|
| 6 |
|
| 7 |
from visual_product_search.embeddings.embed import get_image_embedding, get_text_embedding
|
|
|
|
| 18 |
_Database = None
|
| 19 |
def __init__(self, config_path="config/model.yaml"):
|
| 20 |
try:
|
| 21 |
+
# self.env = environ.Env()
|
| 22 |
+
# environ.Env.read_env(Path(__file__).resolve().parent.parent / ".env")
|
| 23 |
self.config = load_config(config_path)
|
| 24 |
|
| 25 |
+
connections.connect(alias="default",
|
| 26 |
+
uri=os.getenv("DATABASE_URL"),
|
| 27 |
+
user=os.getenv("USER"),
|
| 28 |
+
password=os.getenv("PASSWORD"),
|
| 29 |
+
token=os.getenv("TOKEN"),
|
| 30 |
+
)
|
| 31 |
|
| 32 |
if ProductPredictionPipeline._Database is None:
|
| 33 |
ProductPredictionPipeline._Database = DatabaseSearch(
|
| 34 |
+
collection_name=os.getenv("COLLECTION_NAME")
|
| 35 |
)
|
| 36 |
|
| 37 |
except Exception as e:
|
visual_product_search/pipeline/training_pipeline.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import torch, gc
|
| 2 |
from torch.utils.data import DataLoader
|
| 3 |
import numpy as np
|
| 4 |
-
import
|
| 5 |
from pathlib import Path
|
| 6 |
import sys
|
| 7 |
|
|
@@ -19,8 +19,8 @@ from visual_product_search.exception import ExceptionHandle
|
|
| 19 |
class VisualProductPipeline:
|
| 20 |
def __init__(self, config_path="config/model.yaml"):
|
| 21 |
try:
|
| 22 |
-
self.env = environ.Env()
|
| 23 |
-
environ.Env.read_env(Path(__file__).resolve().parent.parent / ".env")
|
| 24 |
self.config = load_config(config_path)
|
| 25 |
|
| 26 |
self.cache_dir = Path("cache_dir")
|
|
@@ -96,11 +96,11 @@ class VisualProductPipeline:
|
|
| 96 |
try:
|
| 97 |
logging.info("Starting indexing")
|
| 98 |
indexer = DatabaseIndexer(
|
| 99 |
-
uri=
|
| 100 |
-
user=
|
| 101 |
-
password=
|
| 102 |
-
token=
|
| 103 |
-
collection_name=
|
| 104 |
)
|
| 105 |
indexer.insert_embeddings(embeddings, metadata, img_link)
|
| 106 |
indexer.create_index()
|
|
@@ -114,12 +114,12 @@ class VisualProductPipeline:
|
|
| 114 |
logging.info("Starting Pushing model & processor in Hugginface")
|
| 115 |
model.push_to_hub(
|
| 116 |
self.config["model"]["new_model"],
|
| 117 |
-
token=
|
| 118 |
check_pr=False
|
| 119 |
)
|
| 120 |
processor.push_to_hub(
|
| 121 |
self.config["model"]["new_model"],
|
| 122 |
-
token=
|
| 123 |
check_pr=False
|
| 124 |
)
|
| 125 |
logging.info("Model pushed to Hugging Face Hub")
|
|
|
|
| 1 |
import torch, gc
|
| 2 |
from torch.utils.data import DataLoader
|
| 3 |
import numpy as np
|
| 4 |
+
import os
|
| 5 |
from pathlib import Path
|
| 6 |
import sys
|
| 7 |
|
|
|
|
| 19 |
class VisualProductPipeline:
|
| 20 |
def __init__(self, config_path="config/model.yaml"):
|
| 21 |
try:
|
| 22 |
+
# self.env = environ.Env()
|
| 23 |
+
# environ.Env.read_env(Path(__file__).resolve().parent.parent / ".env")
|
| 24 |
self.config = load_config(config_path)
|
| 25 |
|
| 26 |
self.cache_dir = Path("cache_dir")
|
|
|
|
| 96 |
try:
|
| 97 |
logging.info("Starting indexing")
|
| 98 |
indexer = DatabaseIndexer(
|
| 99 |
+
uri=os.getenv("DATABASE_URL"),
|
| 100 |
+
user=os.getenv("USER"),
|
| 101 |
+
password=os.getenv("PASSWORD"),
|
| 102 |
+
token=os.getenv("TOKEN"),
|
| 103 |
+
collection_name=os.getenv("COLLECTION_NAME")
|
| 104 |
)
|
| 105 |
indexer.insert_embeddings(embeddings, metadata, img_link)
|
| 106 |
indexer.create_index()
|
|
|
|
| 114 |
logging.info("Starting Pushing model & processor in Hugginface")
|
| 115 |
model.push_to_hub(
|
| 116 |
self.config["model"]["new_model"],
|
| 117 |
+
token=os.getenv("HF_TOKEN"),
|
| 118 |
check_pr=False
|
| 119 |
)
|
| 120 |
processor.push_to_hub(
|
| 121 |
self.config["model"]["new_model"],
|
| 122 |
+
token=os.getenv("HF_TOKEN"),
|
| 123 |
check_pr=False
|
| 124 |
)
|
| 125 |
logging.info("Model pushed to Hugging Face Hub")
|