admin commited on
Commit
ab0b684
·
1 Parent(s): 28bd077

fix model not found

Browse files
Files changed (4) hide show
  1. app.py +1 -6
  2. insectid/detector.py +2 -5
  3. insectid/identifier.py +3 -9
  4. utils.py +6 -0
app.py CHANGED
@@ -3,13 +3,8 @@ import khandy
3
  import numpy as np
4
  import gradio as gr
5
  from PIL import Image
6
- from huggingface_hub import snapshot_download
7
  from insectid import InsectDetector, InsectIdentifier
8
-
9
- MODEL_DIR = snapshot_download(
10
- "Genius-Society/insecta",
11
- cache_dir="./insectid/__pycache__",
12
- )
13
 
14
 
15
  def infer(filename: str):
 
3
  import numpy as np
4
  import gradio as gr
5
  from PIL import Image
 
6
  from insectid import InsectDetector, InsectIdentifier
7
+ from utils import MODEL_DIR
 
 
 
 
8
 
9
 
10
  def infer(filename: str):
insectid/detector.py CHANGED
@@ -3,15 +3,12 @@ import khandy
3
  import numpy as np
4
  from .base import OnnxModel
5
  from .base import check_image_dtype_and_shape
 
6
 
7
 
8
  class InsectDetector(OnnxModel):
9
  def __init__(self):
10
- current_dir = os.path.dirname(os.path.abspath(__file__))
11
- model_path = os.path.join(
12
- current_dir,
13
- "__pycache__/Genius-Society/insecta/quarrying_insect_detector.onnx",
14
- )
15
  self.input_width = 640
16
  self.input_height = 640
17
  super(InsectDetector, self).__init__(model_path)
 
3
  import numpy as np
4
  from .base import OnnxModel
5
  from .base import check_image_dtype_and_shape
6
+ from utils import MODEL_DIR
7
 
8
 
9
  class InsectDetector(OnnxModel):
10
  def __init__(self):
11
+ model_path = f"{MODEL_DIR}/quarrying_insect_detector.onnx"
 
 
 
 
12
  self.input_width = 640
13
  self.input_height = 640
14
  super(InsectDetector, self).__init__(model_path)
insectid/identifier.py CHANGED
@@ -5,19 +5,13 @@ import numpy as np
5
  from .base import OnnxModel
6
  from collections import OrderedDict
7
  from .base import check_image_dtype_and_shape
 
8
 
9
 
10
  class InsectIdentifier(OnnxModel):
11
  def __init__(self):
12
- current_dir = os.path.dirname(os.path.abspath(__file__))
13
- model_path = os.path.join(
14
- current_dir,
15
- "__pycache__/Genius-Society/insecta/quarrying_insect_identifier.onnx",
16
- )
17
- label_map_path = os.path.join(
18
- current_dir,
19
- "__pycache__/Genius-Society/insecta/quarrying_insectid_label_map.txt",
20
- )
21
  super(InsectIdentifier, self).__init__(model_path)
22
  self.label_name_dict = self._get_label_name_dict(label_map_path)
23
  self.names = [
 
5
  from .base import OnnxModel
6
  from collections import OrderedDict
7
  from .base import check_image_dtype_and_shape
8
+ from utils import MODEL_DIR
9
 
10
 
11
  class InsectIdentifier(OnnxModel):
12
  def __init__(self):
13
+ model_path = f"{MODEL_DIR}/quarrying_insect_identifier.onnx"
14
+ label_map_path = f"{MODEL_DIR}/quarrying_insectid_label_map.txt"
 
 
 
 
 
 
 
15
  super(InsectIdentifier, self).__init__(model_path)
16
  self.label_name_dict = self._get_label_name_dict(label_map_path)
17
  self.names = [
utils.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from huggingface_hub import snapshot_download
2
+
3
+ MODEL_DIR = snapshot_download(
4
+ "Genius-Society/insecta",
5
+ cache_dir="./insectid/__pycache__",
6
+ )