Tugas M8

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

4/30/2021 Resnet

In [ ]:
pip install tensorflow==2.4.0

In [ ]:
pip install opencv-python

In [ ]:
pip install keras

In [ ]:
pip install imageAI

In [1]:
from imageai.Detection import ObjectDetection

In [2]:
detector = ObjectDetection()

In [3]:
import urllib.request
urllib.request.urlretrieve(
'https://gitlab.com/andreass.bayu/imageai-repo/-/blob/master/resnet50_coco_best_v2.1

Out[3]: ('model.h5', <http.client.HTTPMessage at 0x7f467c8e4610>)

In [4]:
model_path = "resnet50_coco_best_v2.1.0.h5"
input_path = "Image.jpg"
output_path = "newimage.jpg"

In [5]:
detector.setModelTypeAsRetinaNet()

In [6]:
detector.setModelPath(model_path)

In [7]:
detector.loadModel()

WARNING:tensorflow:No training configuration found in the save file, so the model wa


s *not* compiled. Compile it manually.

In [8]:
detection = detector.detectObjectsFromImage(input_image=input_path, output_image_pat

In [9]:
for eachItem in detection:
print(eachItem["name"] , " : ", eachItem["percentage_probability"])

car : 90.7205581665039
person : 85.79742908477783
car : 85.58775782585144
car : 83.81378650665283
car : 83.77389311790466
car : 80.09180426597595
bus : 63.896989822387695
person : 63.021254539489746
car : 60.582590103149414
person : 59.995853900909424
car : 58.757615089416504
car : 53.58183979988098
https://hub.mybinder.turing.ac.uk/user/jupyterlab-jupyterlab-demo-cpcvd8gl/lab/tree/demo/Resnet.ipynb 1/2
4/30/2021 Resnet

car : 52.824848890304565
car : 50.204575061798096
car : 50.07892847061157
car : 50.029850006103516

In [10]:
from IPython.display import Image
Image(filename='newimage.jpg')

Out[10]:

https://hub.mybinder.turing.ac.uk/user/jupyterlab-jupyterlab-demo-cpcvd8gl/lab/tree/demo/Resnet.ipynb 2/2
4/30/2021 YOLOv3

In [ ]:
pip install tensorflow==2.4.0

In [ ]:
pip install opencv-python

In [ ]:
pip install keras

In [ ]:
pip install imageAI

In [1]:
from imageai.Detection import ObjectDetection

In [2]:
detector = ObjectDetection ()

In [3]:
import urllib.request
urllib.request.urlretrieve(
'https://gitlab.com/andreass.bayu/imageai-repo/-/raw/master/yolo.h5','modelyolo1.h5'

Out[3]: ('modelyolo1.h5', <http.client.HTTPMessage at 0x7f170c40c610>)

In [4]:
model_path = "modelyolo1.h5"
input_path = "Image.jpg"
output_path = "newimage3.jpg"

In [5]:
detector.setModelTypeAsYOLOv3()

In [6]:
detector.setModelPath(model_path)

In [7]:
detector.loadModel()

In [8]:
detection = detector.detectObjectsFromImage(input_image=input_path, output_image_pat

In [9]:
for eachItem in detection:
print(eachItem["name"] , " : ", eachItem["percentage_probability"])

car : 94.09416317939758
car : 98.34843277931213
car : 99.4688868522644
person : 89.80342745780945
person : 64.68648910522461
person : 62.79137134552002
person : 65.91312289237976
car : 92.38502383232117
car : 55.66313862800598
car : 83.90525579452515
car : 61.971694231033325
car : 92.05581545829773
car : 75.55996179580688
car : 57.99888372421265

https://hub.mybinder.turing.ac.uk/user/jupyterlab-jupyterlab-demo-cpcvd8gl/lab/tree/demo/YOLOv3.ipynb 1/2
4/30/2021 YOLOv3

car : 54.487645626068115
person : 99.16877150535583
car : 96.13478779792786
car : 96.34810090065002
car : 99.38294887542725

In [10]:
from IPython.display import Image
Image(filename='newimage3.jpg')

Out[10]:

https://hub.mybinder.turing.ac.uk/user/jupyterlab-jupyterlab-demo-cpcvd8gl/lab/tree/demo/YOLOv3.ipynb 2/2
4/30/2021 TinyYOLOv3

In [ ]:
pip install tensorflow==2.4.0

In [ ]:
pip install opencv-python

In [ ]:
pip install keras

In [ ]:
pip install imageAI

In [1]:
from imageai.Detection import ObjectDetection

In [2]:
detector = ObjectDetection()

In [3]:
import urllib.request
urllib.request.urlretrieve(
'https://gitlab.com/andreass.bayu/imageai-repo/-/blob/master/yolo-tiny.h5', 'model.h

Out[3]: ('model.h5', <http.client.HTTPMessage at 0x7f48cf3bd690>)

In [4]:
model_path = "yolo-tiny.h5"
input_path = "Image.jpg"
output_path = "newimage2.jpg"

In [5]:
detector.setModelTypeAsTinyYOLOv3()

In [6]:
detector.setModelPath(model_path)

In [7]:
detector.loadModel()

In [8]:
detection = detector.detectObjectsFromImage(input_image=input_path, output_image_pat

In [9]:
for eachItem in detection:
print(eachItem["name"] , " : ", eachItem["percentage_probability"])

car : 56.976598501205444
bus : 53.34131717681885
car : 59.28345322608948
car : 97.18648791313171
car : 97.3617672920227
person : 52.188801765441895
car : 58.66744518280029
car : 63.57458233833313
person : 73.75339269638062
car : 89.5150899887085
car : 72.77529835700989

In [10]:
from IPython.display import Image

https://hub.mybinder.turing.ac.uk/user/jupyterlab-jupyterlab-demo-cpcvd8gl/lab/tree/demo/TinyYOLOv3.ipynb 1/2
4/30/2021 TinyYOLOv3

Image(filename='newimage2.jpg')

Out[10]:

https://hub.mybinder.turing.ac.uk/user/jupyterlab-jupyterlab-demo-cpcvd8gl/lab/tree/demo/TinyYOLOv3.ipynb 2/2

You might also like