Rembg is a tool to remove images background
Use Python's stdlib to hash files
Daniel Nagyd7f023d2cd03
diff --git a/requirements.txt b/requirements.txtindex 3b877d0..0140da8 100644--- a/requirements.txt+++ b/requirements.txt@@ -10,4 +10,3 @@ requests>=2.24.0scipy>=1.5.4pymatting>=1.1.1filetype>=1.0.7-hsh>=1.1.0diff --git a/src/rembg/u2net/detect.py b/src/rembg/u2net/detect.pyindex 6fdc635..6618a7b 100644--- a/src/rembg/u2net/detect.py+++ b/src/rembg/u2net/detect.py@@ -9,7 +9,7 @@ import torchimport torch.nn as nnimport torch.nn.functional as Fimport torchvision-from hsh.library.hash import Hasher+from hashlib import md5from PIL import Imagefrom skimage import transformfrom torchvision import transforms@@ -52,7 +52,7 @@ def download_file_from_google_drive(id, fname, destination):def load_model(model_name: str = "u2net"):- hasher = Hasher()+ hashfile = lambda f: md5(open(f,"rb").read()).hexdigest()if model_name == "u2netp":net = u2net.U2NETP(3, 1)@@ -62,7 +62,7 @@ def load_model(model_name: str = "u2net"):)if (not os.path.exists(path)- or hasher.md5(path) != "e4f636406ca4e2af789941e7f139ee2e"+ or hashfile(path) != "e4f636406ca4e2af789941e7f139ee2e"):download_file_from_google_drive("1rbSTGKAE-MTxBYHd-51l2hMOQPT_7EPy",@@ -78,7 +78,7 @@ def load_model(model_name: str = "u2net"):)if (not os.path.exists(path)- or hasher.md5(path) != "347c3d51b01528e5c6c071e3cff1cb55"+ or hashfile(path) != "347c3d51b01528e5c6c071e3cff1cb55"):download_file_from_google_drive("1ao1ovG1Qtx4b7EoskHXmi2E9rp5CHLcZ",@@ -94,7 +94,7 @@ def load_model(model_name: str = "u2net"):)if (not os.path.exists(path)- or hasher.md5(path) != "09fb4e49b7f785c9f855baf94916840a"+ or hashfile(path) != "09fb4e49b7f785c9f855baf94916840a"):download_file_from_google_drive("1-Yg0cxgrNhHP-016FPdp902BR-kSsA4P",