Mauricio Guerta commited on
Commit
4ff08e8
1 Parent(s): 34f0f30

Remove tmp files

Browse files
app.py CHANGED
@@ -4,7 +4,9 @@ import torch
4
  import json
5
  import yoloxdetect2.helpers as yoloxdetect
6
 
 
7
  model = yoloxdetect.YoloxDetector2('kadirnar/yolox_s-v0.1.1', 'configs.yolox_s', device="cpu", hf_model=True)
 
8
  image_size = 640
9
 
10
  def yolox_inference(
@@ -19,7 +21,8 @@ def yolox_inference(
19
  """
20
 
21
  pred2 = []
22
- if model :
 
23
  model.torchyolo = True
24
  pred2 = model.predict(image_path=image_path, image_size=image_size)
25
 
@@ -48,7 +51,7 @@ def yolox_inference(
48
 
49
 
50
  inputs = [
51
- gr.inputs.Image(type="filepath", label="Input Image"),
52
  ]
53
 
54
  outputs = gr.outputs.Image(type="filepath", label="Output Image")
 
4
  import json
5
  import yoloxdetect2.helpers as yoloxdetect
6
 
7
+ #model = yoloxdetect.YoloxDetector2('./dataset/yolox_s.pth', 'configs.yolox_s', device="cpu", hf_model=True)
8
  model = yoloxdetect.YoloxDetector2('kadirnar/yolox_s-v0.1.1', 'configs.yolox_s', device="cpu", hf_model=True)
9
+
10
  image_size = 640
11
 
12
  def yolox_inference(
 
21
  """
22
 
23
  pred2 = []
24
+ if image_path is not None :
25
+ print(image_path)
26
  model.torchyolo = True
27
  pred2 = model.predict(image_path=image_path, image_size=image_size)
28
 
 
51
 
52
 
53
  inputs = [
54
+ gr.inputs.Image(type="pil", label="Input Image"),
55
  ]
56
 
57
  outputs = gr.outputs.Image(type="filepath", label="Output Image")
configs/__pycache__/__init__.cpython-38.pyc CHANGED
Binary files a/configs/__pycache__/__init__.cpython-38.pyc and b/configs/__pycache__/__init__.cpython-38.pyc differ
 
configs/__pycache__/yolox_s.cpython-38.pyc CHANGED
Binary files a/configs/__pycache__/yolox_s.cpython-38.pyc and b/configs/__pycache__/yolox_s.cpython-38.pyc differ
 
yoloxdetect2/__pycache__/helpers.cpython-38.pyc CHANGED
Binary files a/yoloxdetect2/__pycache__/helpers.cpython-38.pyc and b/yoloxdetect2/__pycache__/helpers.cpython-38.pyc differ
 
yoloxdetect2/helpers.py CHANGED
@@ -6,7 +6,9 @@ import importlib
6
  import torch
7
  import cv2
8
  import os
9
-
 
 
10
 
11
  class YoloxDetector2:
12
  def __init__(
@@ -28,13 +30,14 @@ class YoloxDetector2:
28
 
29
  if self.save:
30
  self.save_path = 'output/result.jpg'
31
-
32
  if hf_model:
33
  self.model_path = attempt_download_from_hub(model_path)
34
 
35
  else:
36
  self.model_path = attempt_download(model_path)
37
-
 
38
  self.load_model()
39
 
40
 
@@ -51,7 +54,10 @@ class YoloxDetector2:
51
 
52
 
53
  def predict(self, image_path, image_size):
54
- image = cv2.imread(image_path)
 
 
 
55
  if image_size is not None:
56
  ratio = min(image_size / image.shape[0], image_size / image.shape[1])
57
  img, _ = preproc(image, input_size=(image_size, image_size))
@@ -61,7 +67,7 @@ class YoloxDetector2:
61
  ratio = min(manuel_size / image.shape[0], manuel_size / image.shape[1])
62
  img, _ = preproc(image, input_size=(manuel_size, manuel_size))
63
  img = torch.from_numpy(img).to(self.device).unsqueeze(0).float()
64
-
65
  prediction_result = self.model(img)
66
  original_predictions = postprocess(
67
  prediction=prediction_result,
 
6
  import torch
7
  import cv2
8
  import os
9
+ from PIL import Image
10
+ from torchvision import transforms
11
+ import numpy
12
 
13
  class YoloxDetector2:
14
  def __init__(
 
30
 
31
  if self.save:
32
  self.save_path = 'output/result.jpg'
33
+
34
  if hf_model:
35
  self.model_path = attempt_download_from_hub(model_path)
36
 
37
  else:
38
  self.model_path = attempt_download(model_path)
39
+
40
+ #self.model_path = model_path
41
  self.load_model()
42
 
43
 
 
54
 
55
 
56
  def predict(self, image_path, image_size):
57
+ #image = cv2.imread(image_path)
58
+
59
+ #img = transforms.ToTensor()(image_path).unsqueeze(0)
60
+ image = opencvImage = cv2.cvtColor(numpy.array(image_path), cv2.COLOR_RGB2BGR)
61
  if image_size is not None:
62
  ratio = min(image_size / image.shape[0], image_size / image.shape[1])
63
  img, _ = preproc(image, input_size=(image_size, image_size))
 
67
  ratio = min(manuel_size / image.shape[0], manuel_size / image.shape[1])
68
  img, _ = preproc(image, input_size=(manuel_size, manuel_size))
69
  img = torch.from_numpy(img).to(self.device).unsqueeze(0).float()
70
+
71
  prediction_result = self.model(img)
72
  original_predictions = postprocess(
73
  prediction=prediction_result,
yoloxdetect2/utils/__pycache__/downloads.cpython-38.pyc CHANGED
Binary files a/yoloxdetect2/utils/__pycache__/downloads.cpython-38.pyc and b/yoloxdetect2/utils/__pycache__/downloads.cpython-38.pyc differ