P
P
Python Newbie2021-07-18 19:35:58
Google
Python Newbie, 2021-07-18 19:35:58

How to remake code for colab?

Hello.

I wrote a little code for object detection. But since it didn't work on my PC, I ran it in colab.

The code:

import os

from imageai.Detection import ObjectDetection



exec_path = os.getcwd()

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath(os.path.join(
    exec_path, "resnet50_coco_best_v2.1.0.h5")
)
detector.loadModel()

list = detector.detectObjectsFromImage(
    input_image=os.path.join(exec_path, "face.jpg"),
    output_image_path=os.path.join(exec_path, "new_objects.jpg")
)


error on startup:
NameError                                 Traceback (most recent call last)
<ipython-input-1-fea08fe8a5c2> in <module>()
      2 
      3 
----> 4 exec_path = os.getcwd()
      5 
      6 detector = ObjectDetection()

NameError: name 'os' is not defined


Screenshot of colab:
ZiS5jUZT.jpg?

How to optimize it for colab?

Link to colab notebook: https://colab.research.google.com/drive/1k6DghagXa...
Thanks in advance

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question