Trash Detection
Trash Detection
Mounted at /content/drive
import numpy as np
import pandas as pd
import tensorflow as tf
from PIL import Image
from matplotlib import pyplot as plt
from [Link] import compat
from [Link] import saved_model_pb2
from [Link] import text_format
import pprint
import json
import os
Processing /content/models/research
Preparing metadata ([Link]) ... object-detection==0.1)
Downloading [Link] (38 kB)
Preparing metadata ([Link]) ... (from object-detection==0.1)
Downloading apache_beam-2.56.0-cp310-cp310-
manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.5/14.5 MB 45.3 MB/s eta [Link]
ent already satisfied: pillow in /usr/local/lib/python3.10/dist-packages (from
object-detection==0.1) (9.4.0)
Requirement already satisfied: lxml in /usr/local/lib/python3.10/dist-packages
(from object-detection==0.1) (4.9.4)
Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-
packages (from object-detection==0.1) (3.7.1)
Requirement already satisfied: Cython in /usr/local/lib/python3.10/dist-
packages (from object-detection==0.1) (3.0.10)
Requirement already satisfied: contextlib2 in /usr/local/lib/python3.10/dist-
packages (from object-detection==0.1) (21.6.0)
Requirement already satisfied: tf-slim in /usr/local/lib/python3.10/dist-
packages (from object-detection==0.1) (1.1.0)
Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages
(from object-detection==0.1) (1.16.0)
Requirement already satisfied: pycocotools in /usr/local/lib/python3.10/dist-
packages (from object-detection==0.1) (2.0.7)
Collecting lvis (from object-detection==0.1)
Downloading [Link] (14 kB)
Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages
(from object-detection==0.1) (1.11.4)
Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-
packages (from object-detection==0.1) (2.0.3)
Collecting tf-models-official>=2.5.1 (from object-detection==0.1)
Downloading tf_models_official-[Link] (2.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.7/2.7 MB 60.0 MB/s eta [Link]
object-detection==0.1)
Downloading tensorflow_io-0.37.0-cp310-cp310-
manylinux_2_17_x86_64.manylinux2014_x86_64.whl (49.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 49.6/49.6 MB 8.7 MB/s eta [Link]
ent already satisfied: keras in /usr/local/lib/python3.10/dist-packages (from
object-detection==0.1) (2.15.0)
Collecting pyparsing==2.4.7 (from object-detection==0.1)
Downloading [Link] (67 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 67.8/67.8 kB 9.0 MB/s eta [Link]
object-detection==0.1)
Downloading [Link] (116 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 116.6/116.6 kB 14.2 MB/s eta [Link]
sacrebleu<=2.2.0->object-detection==0.1)
Downloading [Link] (17 kB)
Requirement already satisfied: regex in /usr/local/lib/python3.10/dist-packages
(from sacrebleu<=2.2.0->object-detection==0.1) (2023.12.25)
Requirement already satisfied: tabulate>=0.8.9 in
/usr/local/lib/python3.10/dist-packages (from sacrebleu<=2.2.0->object-
detection==0.1) (0.9.0)
Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-
packages (from sacrebleu<=2.2.0->object-detection==0.1) (1.25.2)
Collecting colorama (from sacrebleu<=2.2.0->object-detection==0.1)
Downloading [Link] (25 kB)
Requirement already satisfied: gin-config in /usr/local/lib/python3.10/dist-
packages (from tf-models-official>=2.5.1->object-detection==0.1) (0.5.0)
Requirement already satisfied: google-api-python-client>=1.6.7 in
/usr/local/lib/python3.10/dist-packages (from tf-models-official>=2.5.1->object-
detection==0.1) (2.84.0)
Collecting immutabledict (from tf-models-official>=2.5.1->object-
detection==0.1)
Downloading [Link] (4.7 kB)
Requirement already satisfied: kaggle>=1.3.9 in /usr/local/lib/python3.10/dist-
packages (from tf-models-official>=2.5.1->object-detection==0.1) (1.6.12)
Requirement already satisfied: oauth2client in /usr/local/lib/python3.10/dist-
packages (from tf-models-official>=2.5.1->object-detection==0.1) (4.1.3)
Requirement already satisfied: opencv-python-headless in
/usr/local/lib/python3.10/dist-packages (from tf-models-official>=2.5.1->object-
detection==0.1) ([Link])
Requirement already satisfied: psutil>=5.4.3 in /usr/local/lib/python3.10/dist-
packages (from tf-models-official>=2.5.1->object-detection==0.1) (5.9.5)
Requirement already satisfied: py-cpuinfo>=3.3.0 in
/usr/local/lib/python3.10/dist-packages (from tf-models-official>=2.5.1->object-
detection==0.1) (9.0.0)
Requirement already satisfied: pyyaml>=6.0.0 in /usr/local/lib/python3.10/dist-
packages (from tf-models-official>=2.5.1->object-detection==0.1) (6.0.1)
Requirement already satisfied: sentencepiece in /usr/local/lib/python3.10/dist-
packages (from tf-models-official>=2.5.1->object-detection==0.1) (0.1.99)
Collecting seqeval (from tf-models-official>=2.5.1->object-detection==0.1)
Downloading [Link] (43 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.6/43.6 kB 5.0 MB/s eta [Link]
etadata ([Link]) ... ent already satisfied: tensorflow-datasets in
/usr/local/lib/python3.10/dist-packages (from tf-models-official>=2.5.1->object-
detection==0.1) (4.9.4)
Requirement already satisfied: tensorflow-hub>=0.6.0 in
/usr/local/lib/python3.10/dist-packages (from tf-models-official>=2.5.1->object-
detection==0.1) (0.16.1)
Collecting tensorflow-model-optimization>=0.4.1 (from tf-models-
official>=2.5.1->object-detection==0.1)
Downloading tensorflow_model_optimization-[Link] (242 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 242.5/242.5 kB 30.9 MB/s eta [Link]
tf-models-official>=2.5.1->object-detection==0.1)
Downloading tensorflow_text-2.16.1-cp310-cp310-
manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.2/5.2 MB 93.7 MB/s eta [Link]
tf-models-official>=2.5.1->object-detection==0.1)
Downloading tensorflow-2.16.1-cp310-cp310-
manylinux_2_17_x86_64.manylinux2014_x86_64.whl (589.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 589.8/589.8 MB 1.2 MB/s eta [Link]
tf-models-official>=2.5.1->object-detection==0.1)
Downloading tf_keras-[Link] (1.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 80.7 MB/s eta [Link]
ent already satisfied: python-dateutil>=2.8.2 in
/usr/local/lib/python3.10/dist-packages (from pandas->object-detection==0.1)
(2.8.2)
Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-
packages (from pandas->object-detection==0.1) (2023.4)
Requirement already satisfied: tzdata>=2022.1 in
/usr/local/lib/python3.10/dist-packages (from pandas->object-detection==0.1)
(2024.1)
Requirement already satisfied: absl-py>=0.2.2 in
/usr/local/lib/python3.10/dist-packages (from tf-slim->object-detection==0.1)
(1.4.0)
Collecting crcmod<2.0,>=1.7 (from apache-beam->object-detection==0.1)
Downloading [Link] (89 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.7/89.7 kB 12.3 MB/s eta [Link]
etadata ([Link]) ... apache-beam->object-detection==0.1)
Downloading orjson-3.10.3-cp310-cp310-
manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 142.5/142.5 kB 17.9 MB/s eta [Link]
apache-beam->object-detection==0.1)
Downloading dill-[Link].[Link] (151 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 152.0/152.0 kB 20.1 MB/s eta [Link]
etadata ([Link]) ... ent already satisfied: cloudpickle~=2.2.1 in
/usr/local/lib/python3.10/dist-packages (from apache-beam->object-detection==0.1)
(2.2.1)
Collecting fastavro<2,>=0.23.6 (from apache-beam->object-detection==0.1)
Downloading fastavro-1.9.4-cp310-cp310-
manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.1/3.1 MB 64.6 MB/s eta [Link]
apache-beam->object-detection==0.1)
Downloading [Link] (18 kB)
Requirement already satisfied: grpcio!=1.48.0,!=1.59.*,!=1.60.*,!=1.61.*,!
=1.62.0,!=1.62.1,<2,>=1.33.1 in /usr/local/lib/python3.10/dist-packages (from
apache-beam->object-detection==0.1) (1.63.0)
Collecting hdfs<3.0.0,>=2.1.0 (from apache-beam->object-detection==0.1)
Downloading [Link] (43 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.5/43.5 kB 5.5 MB/s eta [Link]
etadata ([Link]) ... ent already satisfied: httplib2<0.23.0,>=0.8 in
/usr/local/lib/python3.10/dist-packages (from apache-beam->object-detection==0.1)
(0.22.0)
Requirement already satisfied: jsonschema<5.0.0,>=4.0.0 in
/usr/local/lib/python3.10/dist-packages (from apache-beam->object-detection==0.1)
(4.19.2)
Requirement already satisfied: jsonpickle<4.0.0,>=3.0.0 in
/usr/local/lib/python3.10/dist-packages (from apache-beam->object-detection==0.1)
(3.0.4)
Collecting objsize<0.8.0,>=0.6.1 (from apache-beam->object-detection==0.1)
Downloading [Link] (11 kB)
Requirement already satisfied: packaging>=22.0 in
/usr/local/lib/python3.10/dist-packages (from apache-beam->object-detection==0.1)
(24.0)
Collecting pymongo<5.0.0,>=3.8.0 (from apache-beam->object-detection==0.1)
Downloading pymongo-4.7.1-cp310-cp310-
manylinux_2_17_x86_64.manylinux2014_x86_64.whl (669 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 670.0/670.0 kB 40.8 MB/s eta [Link]
ent already satisfied: proto-plus<2,>=1.7.1 in /usr/local/lib/python3.10/dist-
packages (from apache-beam->object-detection==0.1) (1.23.0)
Requirement already satisfied: protobuf!=4.0.*,!=4.21.*,!=4.22.0,!=4.23.*,!
=4.24.*,<4.26.0,>=3.20.3 in /usr/local/lib/python3.10/dist-packages (from apache-
beam->object-detection==0.1) (3.20.3)
Requirement already satisfied: pydot<2,>=1.2.0 in
/usr/local/lib/python3.10/dist-packages (from apache-beam->object-detection==0.1)
(1.4.2)
Collecting redis<6,>=5.0.0 (from apache-beam->object-detection==0.1)
Downloading [Link] (251 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 252.0/252.0 kB 24.4 MB/s eta [Link]
ent already satisfied: requests<3.0.0,>=2.24.0 in
/usr/local/lib/python3.10/dist-packages (from apache-beam->object-detection==0.1)
(2.31.0)
Requirement already satisfied: typing-extensions>=3.7.0 in
/usr/local/lib/python3.10/dist-packages (from apache-beam->object-detection==0.1)
(4.11.0)
Collecting zstandard<1,>=0.18.0 (from apache-beam->object-detection==0.1)
Downloading zstandard-0.22.0-cp310-cp310-
manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.4/5.4 MB 68.1 MB/s eta [Link]
ent already satisfied: pyarrow<15.0.0,>=3.0.0 in
/usr/local/lib/python3.10/dist-packages (from apache-beam->object-detection==0.1)
(14.0.2)
Requirement already satisfied: pyarrow-hotfix<1 in
/usr/local/lib/python3.10/dist-packages (from apache-beam->object-detection==0.1)
(0.6)
Collecting js2py<1,>=0.74 (from apache-beam->object-detection==0.1)
Downloading [Link] (1.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.0/1.0 MB 47.4 MB/s eta [Link]
ent already satisfied: cycler>=0.10.0 in /usr/local/lib/python3.10/dist-
packages (from lvis->object-detection==0.1) (0.12.1)
Requirement already satisfied: kiwisolver>=1.1.0 in
/usr/local/lib/python3.10/dist-packages (from lvis->object-detection==0.1) (1.4.5)
Requirement already satisfied: opencv-python>=[Link] in
/usr/local/lib/python3.10/dist-packages (from lvis->object-detection==0.1)
([Link])
Requirement already satisfied: contourpy>=1.0.1 in
/usr/local/lib/python3.10/dist-packages (from matplotlib->object-detection==0.1)
(1.2.1)
Requirement already satisfied: fonttools>=4.22.0 in
/usr/local/lib/python3.10/dist-packages (from matplotlib->object-detection==0.1)
(4.51.0)
Requirement already satisfied: tensorflow-io-gcs-filesystem==0.37.0 in
/usr/local/lib/python3.10/dist-packages (from tensorflow_io->object-detection==0.1)
(0.37.0)
Requirement already satisfied: google-auth<3.0.0dev,>=1.19.0 in
/usr/local/lib/python3.10/dist-packages (from google-api-python-client>=1.6.7->tf-
models-official>=2.5.1->object-detection==0.1) (2.27.0)
Requirement already satisfied: google-auth-httplib2>=0.1.0 in
/usr/local/lib/python3.10/dist-packages (from google-api-python-client>=1.6.7->tf-
models-official>=2.5.1->object-detection==0.1) (0.1.1)
Requirement already satisfied: google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!
=2.3.0,<3.0.0dev,>=1.31.5 in /usr/local/lib/python3.10/dist-packages (from google-
api-python-client>=1.6.7->tf-models-official>=2.5.1->object-detection==0.1)
(2.11.1)
Requirement already satisfied: uritemplate<5,>=3.0.1 in
/usr/local/lib/python3.10/dist-packages (from google-api-python-client>=1.6.7->tf-
models-official>=2.5.1->object-detection==0.1) (4.1.1)
Collecting docopt (from hdfs<3.0.0,>=2.1.0->apache-beam->object-detection==0.1)
Downloading [Link] (25 kB)
Preparing metadata ([Link]) ... ent already satisfied: tzlocal>=1.2 in
/usr/local/lib/python3.10/dist-packages (from js2py<1,>=0.74->apache-beam->object-
detection==0.1) (5.2)
Collecting pyjsparser>=2.5.1 (from js2py<1,>=0.74->apache-beam->object-
detection==0.1)
Downloading [Link] (24 kB)
Preparing metadata ([Link]) ... ent already satisfied: attrs>=22.2.0 in
/usr/local/lib/python3.10/dist-packages (from jsonschema<5.0.0,>=4.0.0->apache-
beam->object-detection==0.1) (23.2.0)
Requirement already satisfied: jsonschema-specifications>=2023.03.6 in
/usr/local/lib/python3.10/dist-packages (from jsonschema<5.0.0,>=4.0.0->apache-
beam->object-detection==0.1) (2023.12.1)
Requirement already satisfied: referencing>=0.28.4 in
/usr/local/lib/python3.10/dist-packages (from jsonschema<5.0.0,>=4.0.0->apache-
beam->object-detection==0.1) (0.35.0)
Requirement already satisfied: rpds-py>=0.7.1 in
/usr/local/lib/python3.10/dist-packages (from jsonschema<5.0.0,>=4.0.0->apache-
beam->object-detection==0.1) (0.18.0)
Requirement already satisfied: certifi>=2023.7.22 in
/usr/local/lib/python3.10/dist-packages (from kaggle>=1.3.9->tf-models-
official>=2.5.1->object-detection==0.1) (2024.2.2)
Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages
(from kaggle>=1.3.9->tf-models-official>=2.5.1->object-detection==0.1) (4.66.2)
Requirement already satisfied: python-slugify in
/usr/local/lib/python3.10/dist-packages (from kaggle>=1.3.9->tf-models-
official>=2.5.1->object-detection==0.1) (8.0.4)
Requirement already satisfied: urllib3 in /usr/local/lib/python3.10/dist-
packages (from kaggle>=1.3.9->tf-models-official>=2.5.1->object-detection==0.1)
(2.0.7)
Requirement already satisfied: bleach in /usr/local/lib/python3.10/dist-
packages (from kaggle>=1.3.9->tf-models-official>=2.5.1->object-detection==0.1)
(6.1.0)
Collecting dnspython<3.0.0,>=1.16.0 (from pymongo<5.0.0,>=3.8.0->apache-beam-
>object-detection==0.1)
Downloading [Link] (307 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 307.7/307.7 kB 29.7 MB/s eta [Link]
ent already satisfied: async-timeout>=4.0.3 in /usr/local/lib/python3.10/dist-
packages (from redis<6,>=5.0.0->apache-beam->object-detection==0.1) (4.0.3)
Requirement already satisfied: charset-normalizer<4,>=2 in
/usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.24.0->apache-beam-
>object-detection==0.1) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-
packages (from requests<3.0.0,>=2.24.0->apache-beam->object-detection==0.1) (3.7)
Requirement already satisfied: astunparse>=1.6.0 in
/usr/local/lib/python3.10/dist-packages (from tensorflow~=2.16.1->tf-models-
official>=2.5.1->object-detection==0.1) (1.6.3)
Requirement already satisfied: flatbuffers>=23.5.26 in
/usr/local/lib/python3.10/dist-packages (from tensorflow~=2.16.1->tf-models-
official>=2.5.1->object-detection==0.1) (24.3.25)
Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in
/usr/local/lib/python3.10/dist-packages (from tensorflow~=2.16.1->tf-models-
official>=2.5.1->object-detection==0.1) (0.5.4)
Requirement already satisfied: google-pasta>=0.1.1 in
/usr/local/lib/python3.10/dist-packages (from tensorflow~=2.16.1->tf-models-
official>=2.5.1->object-detection==0.1) (0.2.0)
Collecting h5py>=3.10.0 (from tensorflow~=2.16.1->tf-models-official>=2.5.1-
>object-detection==0.1)
Downloading h5py-3.11.0-cp310-cp310-
manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.3/5.3 MB 100.1 MB/s eta [Link]
ent already satisfied: libclang>=13.0.0 in /usr/local/lib/python3.10/dist-
packages (from tensorflow~=2.16.1->tf-models-official>=2.5.1->object-
detection==0.1) (18.1.1)
Collecting ml-dtypes~=0.3.1 (from tensorflow~=2.16.1->tf-models-
official>=2.5.1->object-detection==0.1)
Downloading ml_dtypes-0.3.2-cp310-cp310-
manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.2/2.2 MB 92.3 MB/s eta [Link]
ent already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.10/dist-
packages (from tensorflow~=2.16.1->tf-models-official>=2.5.1->object-
detection==0.1) (3.3.0)
Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-
packages (from tensorflow~=2.16.1->tf-models-official>=2.5.1->object-
detection==0.1) (67.7.2)
Requirement already satisfied: termcolor>=1.1.0 in
/usr/local/lib/python3.10/dist-packages (from tensorflow~=2.16.1->tf-models-
official>=2.5.1->object-detection==0.1) (2.4.0)
Requirement already satisfied: wrapt>=1.11.0 in /usr/local/lib/python3.10/dist-
packages (from tensorflow~=2.16.1->tf-models-official>=2.5.1->object-
detection==0.1) (1.14.1)
Collecting tensorboard<2.17,>=2.16 (from tensorflow~=2.16.1->tf-models-
official>=2.5.1->object-detection==0.1)
Downloading [Link] (5.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.5/5.5 MB 104.8 MB/s eta [Link]
object-detection==0.1)
Downloading [Link] (1.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 71.6 MB/s eta [Link]
ent already satisfied: rich in /usr/local/lib/python3.10/dist-packages (from
keras->object-detection==0.1) (13.7.1)
Collecting namex (from keras->object-detection==0.1)
Downloading [Link] (5.8 kB)
Collecting optree (from keras->object-detection==0.1)
Downloading optree-0.11.0-cp310-cp310-
manylinux_2_17_x86_64.manylinux2014_x86_64.whl (311 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 311.2/311.2 kB 37.1 MB/s eta [Link]
ent already satisfied: dm-tree~=0.1.1 in /usr/local/lib/python3.10/dist-
packages (from tensorflow-model-optimization>=0.4.1->tf-models-official>=2.5.1-
>object-detection==0.1) (0.1.8)
Requirement already satisfied: pyasn1>=0.1.7 in /usr/local/lib/python3.10/dist-
packages (from oauth2client->tf-models-official>=2.5.1->object-detection==0.1)
(0.6.0)
Requirement already satisfied: pyasn1-modules>=0.0.5 in
/usr/local/lib/python3.10/dist-packages (from oauth2client->tf-models-
official>=2.5.1->object-detection==0.1) (0.4.0)
Requirement already satisfied: rsa>=3.1.4 in /usr/local/lib/python3.10/dist-
packages (from oauth2client->tf-models-official>=2.5.1->object-detection==0.1)
(4.9)
Requirement already satisfied: markdown-it-py>=2.2.0 in
/usr/local/lib/python3.10/dist-packages (from rich->keras->object-detection==0.1)
(3.0.0)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in
/usr/local/lib/python3.10/dist-packages (from rich->keras->object-detection==0.1)
(2.16.1)
Requirement already satisfied: scikit-learn>=0.21.3 in
/usr/local/lib/python3.10/dist-packages (from seqeval->tf-models-official>=2.5.1-
>object-detection==0.1) (1.2.2)
Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages
(from tensorflow-datasets->tf-models-official>=2.5.1->object-detection==0.1)
(8.1.7)
Requirement already satisfied: etils[enp,epath,etree]>=0.9.0 in
/usr/local/lib/python3.10/dist-packages (from tensorflow-datasets->tf-models-
official>=2.5.1->object-detection==0.1) (1.7.0)
Requirement already satisfied: promise in /usr/local/lib/python3.10/dist-
packages (from tensorflow-datasets->tf-models-official>=2.5.1->object-
detection==0.1) (2.3)
Requirement already satisfied: tensorflow-metadata in
/usr/local/lib/python3.10/dist-packages (from tensorflow-datasets->tf-models-
official>=2.5.1->object-detection==0.1) (1.15.0)
Requirement already satisfied: toml in /usr/local/lib/python3.10/dist-packages
(from tensorflow-datasets->tf-models-official>=2.5.1->object-detection==0.1)
(0.10.2)
Requirement already satisfied: array-record>=0.5.0 in
/usr/local/lib/python3.10/dist-packages (from tensorflow-datasets->tf-models-
official>=2.5.1->object-detection==0.1) (0.5.1)
Requirement already satisfied: wheel<1.0,>=0.23.0 in
/usr/local/lib/python3.10/dist-packages (from astunparse>=1.6.0-
>tensorflow~=2.16.1->tf-models-official>=2.5.1->object-detection==0.1) (0.43.0)
Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-
packages (from etils[enp,epath,etree]>=0.9.0->tensorflow-datasets->tf-models-
official>=2.5.1->object-detection==0.1) (2023.6.0)
Requirement already satisfied: importlib_resources in
/usr/local/lib/python3.10/dist-packages (from etils[enp,epath,etree]>=0.9.0-
>tensorflow-datasets->tf-models-official>=2.5.1->object-detection==0.1) (6.4.0)
Requirement already satisfied: zipp in /usr/local/lib/python3.10/dist-packages
(from etils[enp,epath,etree]>=0.9.0->tensorflow-datasets->tf-models-
official>=2.5.1->object-detection==0.1) (3.18.1)
Requirement already satisfied: googleapis-common-protos<2.0.dev0,>=1.56.2 in
/usr/local/lib/python3.10/dist-packages (from google-api-core!=2.0.*,!=2.1.*,!
=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-api-python-client>=1.6.7->tf-models-
official>=2.5.1->object-detection==0.1) (1.63.0)
Requirement already satisfied: cachetools<6.0,>=2.0.0 in
/usr/local/lib/python3.10/dist-packages (from google-auth<3.0.0dev,>=1.19.0-
>google-api-python-client>=1.6.7->tf-models-official>=2.5.1->object-detection==0.1)
(5.3.3)
Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-
packages (from markdown-it-py>=2.2.0->rich->keras->object-detection==0.1) (0.1.2)
Requirement already satisfied: joblib>=1.1.1 in /usr/local/lib/python3.10/dist-
packages (from scikit-learn>=0.21.3->seqeval->tf-models-official>=2.5.1->object-
detection==0.1) (1.4.0)
Requirement already satisfied: threadpoolctl>=2.0.0 in
/usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.21.3->seqeval->tf-
models-official>=2.5.1->object-detection==0.1) (3.5.0)
Requirement already satisfied: markdown>=2.6.8 in
/usr/local/lib/python3.10/dist-packages (from tensorboard<2.17,>=2.16-
>tensorflow~=2.16.1->tf-models-official>=2.5.1->object-detection==0.1) (3.6)
Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in
/usr/local/lib/python3.10/dist-packages (from tensorboard<2.17,>=2.16-
>tensorflow~=2.16.1->tf-models-official>=2.5.1->object-detection==0.1) (0.7.2)
Requirement already satisfied: werkzeug>=1.0.1 in
/usr/local/lib/python3.10/dist-packages (from tensorboard<2.17,>=2.16-
>tensorflow~=2.16.1->tf-models-official>=2.5.1->object-detection==0.1) (3.0.2)
Requirement already satisfied: webencodings in /usr/local/lib/python3.10/dist-
packages (from bleach->kaggle>=1.3.9->tf-models-official>=2.5.1->object-
detection==0.1) (0.5.1)
Requirement already satisfied: text-unidecode>=1.3 in
/usr/local/lib/python3.10/dist-packages (from python-slugify->kaggle>=1.3.9->tf-
models-official>=2.5.1->object-detection==0.1) (1.3)
Requirement already satisfied: MarkupSafe>=2.1.1 in
/usr/local/lib/python3.10/dist-packages (from werkzeug>=1.0.1-
>tensorboard<2.17,>=2.16->tensorflow~=2.16.1->tf-models-official>=2.5.1->object-
detection==0.1) (2.1.5)
Building wheels for collected packages: object-detection, avro-python3, crcmod,
dill, hdfs, seqeval, pyjsparser, docopt
Building wheel for object-detection ([Link]) ... e=object_detection-0.1-
[Link] size=1697356
sha256=2508ab80a126a1b9a35729ac03205b392b261ac24506dabf4c37a7daae960938
Stored in directory:
/tmp/pip-ephem-wheel-cache-vnyqrbq_/wheels/53/dd/70/2de274d6c443c69d367bd6a5606f95e
5a6df61aacf1435ec0d
Building wheel for avro-python3 ([Link]) ... e=avro_python3-1.10.2-py3-
[Link] size=43992
sha256=3fa10affc24750f2ce98c160ebeffe008333b2730a0f9d269fa79c965a7861a8
Stored in directory:
/root/.cache/pip/wheels/bc/85/62/6cdd81c56f923946b401cecff38055b94c9b766927f7d8ca82
Building wheel for crcmod ([Link]) ... od: filename=crcmod-1.7-cp310-cp310-
linux_x86_64.whl size=31406
sha256=91fb460a741369ecdef93f9eef5e56d43352cb9bb0a947b8a14c78bfac083c1e
Stored in directory:
/root/.cache/pip/wheels/85/4c/07/72215c529bd59d67e3dac29711d7aba1b692f543c808ba9e86
Building wheel for dill ([Link]) ... e=dill-[Link]-[Link]
size=78541 sha256=a3350972b2b68e654783b924c87a6ceecb4ea610ebc608ea99d6117201e36481
Stored in directory:
/root/.cache/pip/wheels/ea/e2/86/64980d90e297e7bf2ce588c2b96e818f5399c515c4bb8a7e4f
Building wheel for hdfs ([Link]) ... e=[Link]
size=34324 sha256=58dd1efad7cb7dca890834e34bfe689bba94927849f4f01b39f86030bb6775e6
Stored in directory:
/root/.cache/pip/wheels/e5/8d/b6/99c1c0a3ac5788c866b0ecd3f48b0134a5910e6ed26011800b
Building wheel for seqeval ([Link]) ... e=[Link]
size=16161 sha256=7825fceb5abdc67daac9ee50db5045cac046fa2fb121cd39a8c88d9b9d948508
Stored in directory:
/root/.cache/pip/wheels/1a/67/4a/ad4082dd7dfc30f2abfe4d80a2ed5926a506eb8a972b4767fa
Building wheel for pyjsparser ([Link]) ... e=pyjsparser-2.7.1-py3-none-
[Link] size=25984
sha256=21bf64ad01b2c43a7453ba94eff5bcd7c44b5a81e805b7542af1843fbff7c79f
Stored in directory:
/root/.cache/pip/wheels/5e/81/26/5956478df303e2bf5a85a5df595bb307bd25948a4bab69f7c7
Building wheel for docopt ([Link]) ... e=[Link]
size=13706 sha256=250d5517e47a3b8883921f258793b522b5357bb195fd55642baa5abc24130cdc
Stored in directory:
/root/.cache/pip/wheels/fc/ab/d4/5da2067ac95b36618c629a5f93f809425700506f72c9732fac
Successfully built object-detection avro-python3 crcmod dill hdfs seqeval
pyjsparser docopt
Installing collected packages: pyjsparser, namex, docopt, crcmod, zstandard,
tensorflow-model-optimization, tensorflow_io, redis, pyparsing, portalocker,
orjson, optree, objsize, ml-dtypes, js2py, immutabledict, h5py, fasteners,
fastavro, dnspython, dill, colorama, avro-python3, tensorboard, sacrebleu, pymongo,
hdfs, seqeval, lvis, keras, tensorflow, apache-beam, tf-keras, tensorflow-text, tf-
models-official, object-detection
Attempting uninstall: pyparsing
Found existing installation: pyparsing 3.1.2
Uninstalling pyparsing-3.1.2:
Successfully uninstalled pyparsing-3.1.2
Attempting uninstall: ml-dtypes
Found existing installation: ml-dtypes 0.2.0
Uninstalling ml-dtypes-0.2.0:
Successfully uninstalled ml-dtypes-0.2.0
Attempting uninstall: h5py
Found existing installation: h5py 3.9.0
Uninstalling h5py-3.9.0:
Successfully uninstalled h5py-3.9.0
Attempting uninstall: tensorboard
Found existing installation: tensorboard 2.15.2
Uninstalling tensorboard-2.15.2:
Successfully uninstalled tensorboard-2.15.2
Attempting uninstall: keras
Found existing installation: keras 2.15.0
Uninstalling keras-2.15.0:
Successfully uninstalled keras-2.15.0
Attempting uninstall: tensorflow
Found existing installation: tensorflow 2.15.0
Uninstalling tensorflow-2.15.0:
Successfully uninstalled tensorflow-2.15.0
Attempting uninstall: tf-keras
Found existing installation: tf_keras 2.15.1
Uninstalling tf_keras-2.15.1:
Successfully uninstalled tf_keras-2.15.1
Successfully installed apache-beam-2.56.0 avro-python3-1.10.2 colorama-0.4.6
crcmod-1.7 dill-[Link] dnspython-2.6.1 docopt-0.6.2 fastavro-1.9.4 fasteners-0.19
h5py-3.11.0 hdfs-2.7.3 immutabledict-4.2.0 js2py-0.74 keras-3.3.3 lvis-0.5.3 ml-
dtypes-0.3.2 namex-0.0.8 object-detection-0.1 objsize-0.7.0 optree-0.11.0 orjson-
3.10.3 portalocker-2.8.2 pyjsparser-2.7.1 pymongo-4.7.1 pyparsing-2.4.7 redis-5.0.4
sacrebleu-2.2.0 seqeval-1.2.2 tensorboard-2.16.2 tensorflow-2.16.1 tensorflow-
model-optimization-0.8.0 tensorflow-text-2.16.1 tensorflow_io-0.37.0 tf-keras-
2.16.0 tf-models-official-2.16.0 zstandard-0.22.0
# visualize detection
def image2np(image):
(w, h) = [Link]
return [Link]([Link]()).reshape((h, w, 3)).astype(np.uint8)
def image2tensor(image):
npim = image2np(image)
return np.expand_dims(npim, axis=0)
# %matplotlib inline
# def detect(detection_graph, test_image_path):
# with detection_graph.as_default():
# gpu_options =
[Link](per_process_gpu_memory_fraction=0.01)
# with
[Link](graph=detection_graph,config=[Link](gpu_opti
ons=gpu_options)) as sess:
# image_tensor =
detection_graph.get_tensor_by_name('image_tensor:0')
# detection_boxes =
detection_graph.get_tensor_by_name('detection_boxes:0')
# detection_scores =
detection_graph.get_tensor_by_name('detection_scores:0')
# detection_classes =
detection_graph.get_tensor_by_name('detection_classes:0')
# num_detections =
detection_graph.get_tensor_by_name('num_detections:0')
# print(detection_classes)
# image = [Link](test_image_path)
# (boxes, scores, classes, num) = [Link](
# [detection_boxes, detection_scores, detection_classes,
num_detections],
# feed_dict={image_tensor: image2tensor(image)}
# )
# npim = image2np(image)
# vis_util.visualize_boxes_and_labels_on_image_array(
# npim,
# [Link](boxes),
# [Link](classes).astype(np.int32),
# [Link](scores),
# category_index,
# use_normalized_coordinates=True,
# line_thickness=15)
# [Link](figsize=(12, 8))
# [Link](npim)
# [Link]()
label_map =
label_map_util.load_labelmap('/content/drive/MyDrive/sunday/[Link]')
categories = label_map_util.convert_label_map_to_categories(label_map,
max_num_classes=60, use_display_name=True)
category_index = label_map_util.create_category_index(categories)
detection_graph =
reconstruct("/content/drive/MyDrive/sunday/ssd_mobilenet_v2_taco_2018_03_29.pb")
# detect(detection_graph,
'/content/drive/MyDrive/kaggle1/kaggle/train/000000_JPG_jpg.rf.1fe2fd57e7442d2d151e
[Link]')
Tensor("detection_classes:0", dtype=float32)
[]
# import cv2
# from [Link] import cv2_imshow
# # Open the input video
# # Open the input video
# cap = [Link]('/content/VID20240505155419.mp4')
# img=[]
# # Process each frame of the video
# while True:
# ret, frame = [Link]()
# if frame is not None:
# # Perform object detection on the frame
# frame_with_detections = detect(detection_graph, [Link](frame))
# if not ret:
# break
# # [Link]()
# [Link]()
# import cv2
# from [Link] import cv2_imshow
# img = []
# import dependencies
from [Link] import display, Javascript, Image
from [Link] import eval_js
from [Link] import cv2_imshow
from base64 import b64decode, b64encode
import cv2
import numpy as np
import PIL
import io
import html
import time
import [Link] as plt
%matplotlib inline
return img
# function to convert OpenCV Rectangle bounding box image into base64 byte
string to be overlayed on video stream
def bbox_to_bytes(bbox_array):
"""
Params:
bbox_array: Numpy array (pixels) containing rectangle to overlay on
video stream.
Returns:
bytes: Base64 image byte string
"""
# convert array into PIL image
bbox_PIL = [Link](bbox_array, 'RGBA')
iobuf = [Link]()
# format bbox into png for return
bbox_PIL.save(iobuf, format='png')
# format return string
bbox_bytes = 'data:image/png;base64,
{}'.format((str(b64encode([Link]()), 'utf-8')))
return bbox_bytes
# JavaScript to properly create our live video stream using our webcam as input
def video_stream():
js = Javascript('''
var video;
var div = null;
var stream;
var captureCanvas;
var imgElement;
var labelElement;
function removeDom() {
[Link]()[0].stop();
[Link]();
[Link]();
video = null;
div = null;
stream = null;
imgElement = null;
captureCanvas = null;
labelElement = null;
}
function onAnimationFrame() {
if (!shutdown) {
[Link](onAnimationFrame);
}
if (pendingResolve) {
var result = "";
if (!shutdown) {
[Link]('2d').drawImage(video, 0, 0, 640, 480);
result = [Link]('image/jpeg', 0.8)
}
var lp = pendingResolve;
pendingResolve = null;
lp(result);
}
}
div = [Link]('div');
[Link] = '2px solid black';
[Link] = '3px';
[Link] = '100%';
[Link] = '600px';
[Link](div);
video = [Link]('video');
[Link] = 'block';
[Link] = [Link] - 6;
[Link]('playsinline', '');
[Link] = () => { shutdown = true; };
stream = await [Link](
{video: { facingMode: "environment"}});
[Link](video);
imgElement = [Link]('img');
[Link] = 'absolute';
[Link] = 1;
[Link] = () => { shutdown = true; };
[Link](imgElement);
[Link] = stream;
await [Link]();
captureCanvas = [Link]('canvas');
[Link] = 640; //[Link];
[Link] = 480; //[Link];
[Link](onAnimationFrame);
return stream;
}
async function stream_frame(label, imgData) {
if (shutdown) {
removeDom();
shutdown = false;
return '';
}
if (imgData != "") {
var videoRect = [Link]()[0];
[Link] = [Link] + "px";
[Link] = [Link] + "px";
[Link] = [Link] + "px";
[Link] = [Link] + "px";
[Link] = imgData;
}
display(js)
# [Link]()
print(len(detections))
# print(detections[0].shape)
# print(detections[1].shape)
# print(detections[2].shape)
# print(detections[3].shape)
# print(detections[4].shape)
# print(detections[5].shape)
print(len(img))
print(img[0])
[Link]()