Kroy commited on
Commit
652aa0e
·
1 Parent(s): 59f8110

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -37,18 +37,7 @@ MODEL_DIR = os.path.join(ROOT_DIR, "logs")
37
  # Local path to trained weights file
38
  COCO_MODEL_PATH = os.path.join(ROOT_DIR, "mask_rcnn_coco.h5")
39
  os.system("pip install pycocotools==2.0.0")
40
- K.clear_session()
41
 
42
- if not os.path.exists(COCO_MODEL_PATH):
43
- utils.download_trained_weights(COCO_MODEL_PATH)
44
-
45
- class InferenceConfig(coco.CocoConfig):
46
- GPU_COUNT = 1
47
- IMAGES_PER_GPU = 1
48
- config = InferenceConfig()
49
-
50
- model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config)
51
- model.load_weights(COCO_MODEL_PATH, by_name=True)
52
 
53
 
54
  # Define a function to handle the GET request at `/generate`
@@ -63,7 +52,18 @@ def generate(path: str):
63
  can be found [here](<https://huggingface.co/philschmid/bart-large-cnn-samsum>).
64
  """
65
  # Use the pipeline to generate text from the given input text
 
 
 
 
 
 
 
 
 
66
 
 
 
67
  r = requests.get(path, stream=True)
68
  img = Image.open(io.BytesIO(r.content)).convert('RGB')
69
  open_cv_image = np.array(img)
 
37
  # Local path to trained weights file
38
  COCO_MODEL_PATH = os.path.join(ROOT_DIR, "mask_rcnn_coco.h5")
39
  os.system("pip install pycocotools==2.0.0")
 
40
 
 
 
 
 
 
 
 
 
 
 
41
 
42
 
43
  # Define a function to handle the GET request at `/generate`
 
52
  can be found [here](<https://huggingface.co/philschmid/bart-large-cnn-samsum>).
53
  """
54
  # Use the pipeline to generate text from the given input text
55
+ K.clear_session()
56
+
57
+ if not os.path.exists(COCO_MODEL_PATH):
58
+ utils.download_trained_weights(COCO_MODEL_PATH)
59
+
60
+ class InferenceConfig(coco.CocoConfig):
61
+ GPU_COUNT = 1
62
+ IMAGES_PER_GPU = 1
63
+ config = InferenceConfig()
64
 
65
+ model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config)
66
+ model.load_weights(COCO_MODEL_PATH, by_name=True)
67
  r = requests.get(path, stream=True)
68
  img = Image.open(io.BytesIO(r.content)).convert('RGB')
69
  open_cv_image = np.array(img)