Loading
4 Follower
2 Following
shraddhaa_mohan
Shraddhaa Mohan

Organization

SSN College of Engineering

Location

Chennai, IN

Badges

5
4
3

Connect

Activity

Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
Jan
Feb
Mar
Apr
Mon
Wed
Fri

Ratings Progression

Loading...

Challenge Categories

Loading...

Challenges Entered

Latest submissions

See All
graded 222949
graded 222940

Latest submissions

See All
failed 209364
failed 209361
failed 209358

Machine Learning for detection of early onset of Alzheimers

Latest submissions

See All
graded 140414
failed 140408
graded 140389

3D Seismic Image Interpretation by Machine Learning

Latest submissions

No submissions made in this challenge.

Multi-Agent Reinforcement Learning on Trains

Latest submissions

No submissions made in this challenge.

A benchmark for image-based food recognition

Latest submissions

See All
graded 115164
graded 113600
graded 113474

Latest submissions

No submissions made in this challenge.

Predicting smell of molecular compounds

Latest submissions

See All
graded 91360
graded 91359
graded 91356

Latest submissions

No submissions made in this challenge.

Latest submissions

See All
graded 107133
graded 107131
graded 107130

Latest submissions

See All
failed 108475
graded 107464
graded 107460

Grouping/Sorting players into their respective teams

Latest submissions

See All
graded 85577
graded 85573
graded 85571

Latest submissions

See All
graded 12586
graded 11549
graded 11547

5 Problems 15 Days. Can you solve it all?

Latest submissions

No submissions made in this challenge.

Sample-efficient reinforcement learning in Minecraft

Latest submissions

No submissions made in this challenge.

Recognise Handwritten Digits

Latest submissions

See All
graded 60266

Online News Prediction

Latest submissions

No submissions made in this challenge.

5 Problems 15 Days. Can you solve it all?

Latest submissions

See All
graded 64385
graded 64384
ready 64383

Help improve humanitarian crisis response through better NLP modeling

Latest submissions

See All
graded 58164
graded 58163
graded 58162

Latest submissions

No submissions made in this challenge.

A new benchmark for Artificial Intelligence (AI) research in Reinforcement Learning

Latest submissions

No submissions made in this challenge.

5 PROBLEMS 3 WEEKS. CAN YOU SOLVE THEM ALL?

Latest submissions

No submissions made in this challenge.

Real Time Mask Detection

Latest submissions

See All
graded 67780
graded 67779
graded 67777

Latest submissions

See All
graded 69090

Classify Scrambled Text

Latest submissions

See All
graded 70072
graded 70071
failed 70070
Participant Rating
rohitmidha23 265
shivam 136
contrebande 0
sanjaypokkali 221
Participant Rating
rohitmidha23 265
sanjaypokkali 221

Food Recognition Challenge

MaskRCNN integrated with WandB and DIRECT SUBMIT FROM COLAB!

Over 3 years ago

Hi everyone!

Open In Colab

@rohitmidha23 and me have been following this challenge for quite a while. We have written a starter notebook using MaskRCNN. We further integrate MaskRCNN with WandB which really helps to keep track of the various experiments that anyone might want to run. Check out our runs here

We also added functionality to view predictions of the model on the validation set as the model trains.

You can find the notebook @ https://colab.research.google.com/drive/1D8jC9GdHhCyoGB-8bJogW-lSO21MeTKF?usp=sharing

We trained the model on 40 classes alone due to Colab’s timing restrictions. However we provide a GitHub repo using which you can train on the entire dataset.

We also made a submission repo, using which you can submit models trained using the code above. The model we trained gets a precision score of 0.135 on the test set.

We hope that this notebook helps out other participants.

As always we are open to any feedback, suggestions and criticism!

If you found our work helpful, do drop us a :heart:!

Submission problem, can't start evaluation issue

Over 3 years ago

I tried just now as well, and have the same issue @shivam

Train using mmdetection and submit via Colab (Round 2)!

About 4 years ago

Hey,

I think the baseline(food-round2) was created using this config file. You can compare this with the config you are using right now and try find out where the issue might be.

Cannot upload to the git even git lfs is checked ... windows using git tortoise

About 4 years ago

Not unless it would be something compute intensive. Have you managed to get your code running locally using nvdia-docker, if your code works locally on nvidia-docker then maybe it is a server issue.

Step by step tutorials

About 4 years ago

I’m not quite sure what errors you ran into while changing the model, I’ve made a notebook that does exactly that and makes a submission directly on colab. You can check it out here Train using mmdetection and submit via Colab!

Regards
Shraddhaa

Cannot upload to the git even git lfs is checked ... windows using git tortoise

About 4 years ago

Clearly for some reason the module has not been installed in your docker image. I would suggest adding RUN pip install scikit-image in your Dockerfile. Since this is a docker issue, I think you could find the problem by debugging locally. It is explained in the baseline repo’s readme.

It seems you have a submission in progress already, I hope you’ve managed to solve your issue.

Train using mmdetection and submit via Colab (Round 2)!

About 4 years ago

LEARN HOW TO SUBMIT | NO SSH | ON COLAB | DIRECTLY!!!
Hey everyone,

Since a lot of people seem to be finding it difficult to submit, we’ve converted the baseline code using mmdetection into a colab notebook which allows you to submit directly via colab. If you are not using mmdetection you can still check this notebook out and have a look at the submission steps. If you have any issues or need any help do feel free to post here.

MMdetection Starter(DIRECT SUBMIT!)

Regards
AICrowd Team

Cannot upload to the git even git lfs is checked ... windows using git tortoise

About 4 years ago

Can you check your .gitignore and see if .pth is mentioned there, if so remove it

Not able to ssh to gitlab

About 4 years ago

Can you try running ssh -T git@gitlab.com after adding your generated key to your gitlab account ? Steps are here

New Starter Notebook + paperspace

About 4 years ago

Hey everyone,

We know that computing resources may be really difficult to come by, especially for beginners, so we have written a new starter notebook that allows you to train a MaskRCNN model directly on Colab.

Mask-RCNN Food Starter Code

Open In Colab

This dataset and notebook correspond to the Food Recognition Challenge being held on AICrowd.

In this Notebook, we will first do an analysis of the Food Recognition Dataset and then use maskrcnn for training on the dataset.

The ChallengeΒΆ

  • Given Images of Food, we are asked to provide Instance Segmentation over the images for the food items.
  • The Training Data is provided in the COCO format, making it simpler to load with pre-available COCO data processors in popular libraries.
  • The test set provided in the public dataset is similar to Validation set, but with no annotations.
  • The test set after submission is much larger and contains private images upon which every submission is evaluated.
  • Pariticipants have to submit their trained model along with trained weights. Immediately after the submission the AICrowd Grader picks up the submitted model and produces inference on the private test set using Cloud GPUs.
  • This requires Users to structure their repositories and follow a provided paradigm for submission.
  • The AICrowd AutoGrader picks up the Dockerfile provided with the repository, builds it and then mounts the tests folder in the container. Once inference is made, the final results are checked with the ground truth.

For more submission related information, please check the AIcrowd Challenge page and the starter kit.

The NotebookΒΆ

  • Installation of MaskRCNN
  • Using MatterPort MaskRCNN Library and Making local inference with it
  • Local Evaluation Using Matterport MaskRCNN

A bonus section on other resources to read is also added!

Dataset DownloadΒΆ

Note: By downloading this data you are argeeing to the competition rules specified here

In [0]:
!wget -q https://s3.eu-central-1.wasabisys.com/aicrowd-public-datasets/myfoodrepo/round-2/train.tar.gz
!wget -q https://s3.eu-central-1.wasabisys.com/aicrowd-public-datasets/myfoodrepo/round-2/val.tar.gz
In [0]:
!mkdir data
!mkdir data/val
!mkdir data/train
!tar -xf train.tar.gz -C data/train
!tar -xf val.tar.gz -C data/val

InstallationΒΆ

In [0]:
#Directories present
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import os
for dirname, _, filenames in os.walk('data/'):
        print(dirname)
data/
data/train
data/train/images
data/val
data/val/images
data/val/test_images
data/val/test_images/images
In [0]:
import warnings
warnings.filterwarnings("ignore")
In [0]:
pip install -q -U numpy==1.16.1
In [0]:
import os 
import sys
import random
import math
import numpy as np
import cv2
import matplotlib.pyplot as plt
import json
from imgaug import augmenters as iaa
from tqdm import tqdm
import pandas as pd 
import glob
In [0]:
!pip install -q tensorflow-gpu==1.13.1
In [0]:
import tensorflow as tf
tf.__version__
Out[0]:
'1.15.0'
In [0]:
DATA_DIR = 'data'
# Directory to save logs and trained model
ROOT_DIR = 'working'
In [0]:
!git clone https://www.github.com/matterport/Mask_RCNN.git
os.chdir('Mask_RCNN')
!pip install -q -r requirements.txt
!python setup.py -q install
In [0]:
# Import Mask RCNN
sys.path.append(os.path.join('.', 'Mask_RCNN'))  # To find local version of the library
from mrcnn.config import Config
from mrcnn import utils
import mrcnn.model as modellib
from mrcnn import visualize
from mrcnn.model import log
Using TensorFlow backend.
In [0]:
!pip uninstall pycocotools -y
!pip install -q git+https://github.com/waleedka/coco.git#subdirectory=PythonAPI
In [0]:
from mrcnn import utils
import numpy as np

from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval
from pycocotools import mask as maskUtils

MaskRCNNΒΆ

To train MaskRCNN, two things we have to define FoodChallengeDataset that implements the Dataset class of MaskRCNN and FoodChallengeConfig that implements the Config class.

The FoodChallengeDataset helps define certain functions that allow us to load the data.

The FoodChallengeConfig gives the information like NUM_CLASSES, BACKBONE, etc.

In [0]:
class FoodChallengeDataset(utils.Dataset):
    def load_dataset(self, dataset_dir, load_small=False, return_coco=True):
        """ Loads dataset released for the AICrowd Food Challenge
            Params:
                - dataset_dir : root directory of the dataset (can point to the train/val folder)
                - load_small : Boolean value which signals if the annotations for all the images need to be loaded into the memory,
                               or if only a small subset of the same should be loaded into memory
        """
        self.load_small = load_small
        if self.load_small:
            annotation_path = os.path.join(dataset_dir, "annotation-small.json")
        else:
            annotation_path = os.path.join(dataset_dir, "annotations.json")

        image_dir = os.path.join(dataset_dir, "images")
        print("Annotation Path ", annotation_path)
        print("Image Dir ", image_dir)
        assert os.path.exists(annotation_path) and os.path.exists(image_dir)

        self.coco = COCO(annotation_path)
        self.image_dir = image_dir

        # Load all classes (Only Building in this version)
        classIds = self.coco.getCatIds()

        # Load all images
        image_ids = list(self.coco.imgs.keys())

        # register classes
        for _class_id in classIds:
            self.add_class("crowdai-food-challenge", _class_id, self.coco.loadCats(_class_id)[0]["name"])

        # Register Images
        for _img_id in image_ids:
            assert(os.path.exists(os.path.join(image_dir, self.coco.imgs[_img_id]['file_name'])))
            self.add_image(
                "crowdai-food-challenge", image_id=_img_id,
                path=os.path.join(image_dir, self.coco.imgs[_img_id]['file_name']),
                width=self.coco.imgs[_img_id]["width"],
                height=self.coco.imgs[_img_id]["height"],
                annotations=self.coco.loadAnns(self.coco.getAnnIds(
                                            imgIds=[_img_id],
                                            catIds=classIds,
                                            iscrowd=None)))

        if return_coco:
            return self.coco

    def load_mask(self, image_id):
        """ Loads instance mask for a given image
              This function converts mask from the coco format to a
              a bitmap [height, width, instance]
            Params:
                - image_id : reference id for a given image

            Returns:
                masks : A bool array of shape [height, width, instances] with
                    one mask per instance
                class_ids : a 1D array of classIds of the corresponding instance masks
                    (In this version of the challenge it will be of shape [instances] and always be filled with the class-id of the "Building" class.)
        """

        image_info = self.image_info[image_id]
        assert image_info["source"] == "crowdai-food-challenge"

        instance_masks = []
        class_ids = []
        annotations = self.image_info[image_id]["annotations"]
        # Build mask of shape [height, width, instance_count] and list
        # of class IDs that correspond to each channel of the mask.
        for annotation in annotations:
            class_id = self.map_source_class_id(
                "crowdai-food-challenge.{}".format(annotation['category_id']))
            if class_id:
                m = self.annToMask(annotation,  image_info["height"],
                                                image_info["width"])
                # Some objects are so small that they're less than 1 pixel area
                # and end up rounded out. Skip those objects.
                if m.max() < 1:
                    continue

                # Ignore the notion of "is_crowd" as specified in the coco format
                # as we donot have the said annotation in the current version of the dataset

                instance_masks.append(m)
                class_ids.append(class_id)
        # Pack instance masks into an array
        if class_ids:
            mask = np.stack(instance_masks, axis=2)
            class_ids = np.array(class_ids, dtype=np.int32)
            return mask, class_ids
        else:
            # Call super class to return an empty mask
            return super(FoodChallengeDataset, self).load_mask(image_id)


    def image_reference(self, image_id):
        """Return a reference for a particular image

            Ideally you this function is supposed to return a URL
            but in this case, we will simply return the image_id
        """
        return "crowdai-food-challenge::{}".format(image_id)
    # The following two functions are from pycocotools with a few changes.

    def annToRLE(self, ann, height, width):
        """
        Convert annotation which can be polygons, uncompressed RLE to RLE.
        :return: binary mask (numpy 2D array)
        """
        segm = ann['segmentation']
        if isinstance(segm, list):
            # polygon -- a single object might consist of multiple parts
            # we merge all parts into one mask rle code
            rles = maskUtils.frPyObjects(segm, height, width)
            rle = maskUtils.merge(rles)
        elif isinstance(segm['counts'], list):
            # uncompressed RLE
            rle = maskUtils.frPyObjects(segm, height, width)
        else:
            # rle
            rle = ann['segmentation']
        return rle

    def annToMask(self, ann, height, width):
        """
        Convert annotation which can be polygons, uncompressed RLE, or RLE to binary mask.
        :return: binary mask (numpy 2D array)
        """
        rle = self.annToRLE(ann, height, width)
        m = maskUtils.decode(rle)
        return m
In [0]:
class FoodChallengeConfig(Config):
    """Configuration for training on data in MS COCO format.
    Derives from the base Config class and overrides values specific
    to the COCO dataset.
    """
    # Give the configuration a recognizable name
    NAME = "crowdai-food-challenge"

    # We use a GPU with 12GB memory, which can fit two images.
    # Adjust down if you use a smaller GPU.
    IMAGES_PER_GPU = 4

    # Uncomment to train on 8 GPUs (default is 1)
    GPU_COUNT = 1
    BACKBONE = 'resnet50'
    # Number of classes (including background)
    NUM_CLASSES = 62  # 1 Background + 61 classes

    STEPS_PER_EPOCH=150
    VALIDATION_STEPS=50

    LEARNING_RATE=0.001
    IMAGE_MAX_DIM=256
    IMAGE_MIN_DIM=256
In [0]:
config = FoodChallengeConfig()
config.display()
Configurations:
BACKBONE                       resnet50
BACKBONE_STRIDES               [4, 8, 16, 32, 64]
BATCH_SIZE                     4
BBOX_STD_DEV                   [0.1 0.1 0.2 0.2]
COMPUTE_BACKBONE_SHAPE         None
DETECTION_MAX_INSTANCES        100
DETECTION_MIN_CONFIDENCE       0.7
DETECTION_NMS_THRESHOLD        0.3
FPN_CLASSIF_FC_LAYERS_SIZE     1024
GPU_COUNT                      1
GRADIENT_CLIP_NORM             5.0
IMAGES_PER_GPU                 4
IMAGE_CHANNEL_COUNT            3
IMAGE_MAX_DIM                  256
IMAGE_META_SIZE                74
IMAGE_MIN_DIM                  256
IMAGE_MIN_SCALE                0
IMAGE_RESIZE_MODE              square
IMAGE_SHAPE                    [256 256   3]
LEARNING_MOMENTUM              0.9
LEARNING_RATE                  0.001
LOSS_WEIGHTS                   {'rpn_class_loss': 1.0, 'rpn_bbox_loss': 1.0, 'mrcnn_class_loss': 1.0, 'mrcnn_bbox_loss': 1.0, 'mrcnn_mask_loss': 1.0}
MASK_POOL_SIZE                 14
MASK_SHAPE                     [28, 28]
MAX_GT_INSTANCES               100
MEAN_PIXEL                     [123.7 116.8 103.9]
MINI_MASK_SHAPE                (56, 56)
NAME                           crowdai-food-challenge
NUM_CLASSES                    62
POOL_SIZE                      7
POST_NMS_ROIS_INFERENCE        1000
POST_NMS_ROIS_TRAINING         2000
PRE_NMS_LIMIT                  6000
ROI_POSITIVE_RATIO             0.33
RPN_ANCHOR_RATIOS              [0.5, 1, 2]
RPN_ANCHOR_SCALES              (32, 64, 128, 256, 512)
RPN_ANCHOR_STRIDE              1
RPN_BBOX_STD_DEV               [0.1 0.1 0.2 0.2]
RPN_NMS_THRESHOLD              0.7
RPN_TRAIN_ANCHORS_PER_IMAGE    256
STEPS_PER_EPOCH                150
TOP_DOWN_PYRAMID_SIZE          256
TRAIN_BN                       False
TRAIN_ROIS_PER_IMAGE           200
USE_MINI_MASK                  True
USE_RPN_ROIS                   True
VALIDATION_STEPS               50
WEIGHT_DECAY                   0.0001


You can change other values in the FoodChallengeConfig as well and try out different combinations for best results!

In [0]:
!mkdir pretrained
In [0]:
PRETRAINED_MODEL_PATH = os.path.join("pretrained", "mask_rcnn_coco.h5")
LOGS_DIRECTORY = os.path.join(ROOT_DIR, "logs")
In [0]:
if not os.path.exists(PRETRAINED_MODEL_PATH):
    utils.download_trained_weights(PRETRAINED_MODEL_PATH)
Downloading pretrained model to pretrained/mask_rcnn_coco.h5 ...
... done downloading pretrained model!
In [0]:
from keras import backend as K
K.tensorflow_backend._get_available_gpus()
In [0]:
import keras.backend
K = keras.backend.backend()
if K=='tensorflow':
    keras.backend.common.image_dim_ordering()
model = modellib.MaskRCNN(mode="training", config=config, model_dir=LOGS_DIRECTORY)
model_path = PRETRAINED_MODEL_PATH
model.load_weights(model_path, by_name=True, exclude=[
        "mrcnn_class_logits", "mrcnn_bbox_fc",
        "mrcnn_bbox", "mrcnn_mask"])
In [0]:
dataset_train = FoodChallengeDataset()
dataset_train.load_dataset('/content/data/train', load_small=False)
dataset_train.prepare()
Annotation Path  /content/data/train/annotations.json
Image Dir  /content/data/train/images
loading annotations into memory...
Done (t=0.58s)
creating index...
index created!
In [0]:
dataset_val = FoodChallengeDataset()
val_coco = dataset_val.load_dataset(dataset_dir='/content/data/val', load_small=False, return_coco=True)
dataset_val.prepare()
Annotation Path  /content/data/val/annotations.json
Image Dir  /content/data/val/images
loading annotations into memory...
Done (t=0.03s)
creating index...
index created!
In [0]:
class_names = dataset_train.class_names
# If you don't have the correct classes here, there must be some error in your DatasetConfig
assert len(class_names)==62, "Please check DatasetConfig"
class_names

Lets start training!!ΒΆ

In [0]:
print("Training network")
model.train(dataset_train, dataset_val,
            learning_rate=config.LEARNING_RATE,
            epochs=15,
            layers='heads')
Training network

Starting at epoch 0. LR=0.001

Checkpoint Path: working/logs/crowdai-food-challenge20200325T1633/mask_rcnn_crowdai-food-challenge_{epoch:04d}.h5
Selecting layers to train
fpn_c5p5               (Conv2D)
fpn_c4p4               (Conv2D)
fpn_c3p3               (Conv2D)
fpn_c2p2               (Conv2D)
fpn_p5                 (Conv2D)
fpn_p2                 (Conv2D)
fpn_p3                 (Conv2D)
fpn_p4                 (Conv2D)
In model:  rpn_model
    rpn_conv_shared        (Conv2D)
    rpn_class_raw          (Conv2D)
    rpn_bbox_pred          (Conv2D)
mrcnn_mask_conv1       (TimeDistributed)
mrcnn_mask_bn1         (TimeDistributed)
mrcnn_mask_conv2       (TimeDistributed)
mrcnn_mask_bn2         (TimeDistributed)
mrcnn_class_conv1      (TimeDistributed)
mrcnn_class_bn1        (TimeDistributed)
mrcnn_mask_conv3       (TimeDistributed)
mrcnn_mask_bn3         (TimeDistributed)
mrcnn_class_conv2      (TimeDistributed)
mrcnn_class_bn2        (TimeDistributed)
mrcnn_mask_conv4       (TimeDistributed)
mrcnn_mask_bn4         (TimeDistributed)
mrcnn_bbox_fc          (TimeDistributed)
mrcnn_mask_deconv      (TimeDistributed)
mrcnn_class_logits     (TimeDistributed)
mrcnn_mask             (TimeDistributed)
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/optimizers.py:793: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.

WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:1033: The name tf.assign_add is deprecated. Please use tf.compat.v1.assign_add instead.

WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:1020: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.

WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/callbacks.py:1122: The name tf.summary.merge_all is deprecated. Please use tf.compat.v1.summary.merge_all instead.

WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/callbacks.py:1125: The name tf.summary.FileWriter is deprecated. Please use tf.compat.v1.summary.FileWriter instead.

Epoch 1/15
150/150 [==============================] - 250s 2s/step - loss: 2.4813 - rpn_class_loss: 0.0334 - rpn_bbox_loss: 0.5775 - mrcnn_class_loss: 0.4669 - mrcnn_bbox_loss: 0.6819 - mrcnn_mask_loss: 0.7217 - val_loss: 2.2839 - val_rpn_class_loss: 0.0288 - val_rpn_bbox_loss: 0.6724 - val_mrcnn_class_loss: 0.2742 - val_mrcnn_bbox_loss: 0.6156 - val_mrcnn_mask_loss: 0.6929
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/callbacks.py:1265: The name tf.Summary is deprecated. Please use tf.compat.v1.Summary instead.

Epoch 2/15
150/150 [==============================] - 198s 1s/step - loss: 2.1028 - rpn_class_loss: 0.0300 - rpn_bbox_loss: 0.5362 - mrcnn_class_loss: 0.3526 - mrcnn_bbox_loss: 0.5183 - mrcnn_mask_loss: 0.6656 - val_loss: 2.2352 - val_rpn_class_loss: 0.0290 - val_rpn_bbox_loss: 0.6337 - val_mrcnn_class_loss: 0.3400 - val_mrcnn_bbox_loss: 0.5495 - val_mrcnn_mask_loss: 0.6830
Epoch 3/15
150/150 [==============================] - 198s 1s/step - loss: 2.0055 - rpn_class_loss: 0.0277 - rpn_bbox_loss: 0.5944 - mrcnn_class_loss: 0.2881 - mrcnn_bbox_loss: 0.4785 - mrcnn_mask_loss: 0.6168 - val_loss: 2.2014 - val_rpn_class_loss: 0.0343 - val_rpn_bbox_loss: 0.6598 - val_mrcnn_class_loss: 0.3873 - val_mrcnn_bbox_loss: 0.5100 - val_mrcnn_mask_loss: 0.6101
Epoch 4/15
150/150 [==============================] - 198s 1s/step - loss: 1.8439 - rpn_class_loss: 0.0282 - rpn_bbox_loss: 0.4459 - mrcnn_class_loss: 0.3620 - mrcnn_bbox_loss: 0.4506 - mrcnn_mask_loss: 0.5572 - val_loss: 1.7891 - val_rpn_class_loss: 0.0200 - val_rpn_bbox_loss: 0.3661 - val_mrcnn_class_loss: 0.3545 - val_mrcnn_bbox_loss: 0.5030 - val_mrcnn_mask_loss: 0.5455
Epoch 5/15
150/150 [==============================] - 198s 1s/step - loss: 1.8198 - rpn_class_loss: 0.0255 - rpn_bbox_loss: 0.5154 - mrcnn_class_loss: 0.3380 - mrcnn_bbox_loss: 0.4415 - mrcnn_mask_loss: 0.4993 - val_loss: 2.1075 - val_rpn_class_loss: 0.0373 - val_rpn_bbox_loss: 0.8661 - val_mrcnn_class_loss: 0.2930 - val_mrcnn_bbox_loss: 0.4375 - val_mrcnn_mask_loss: 0.4737
Epoch 6/15
150/150 [==============================] - 199s 1s/step - loss: 1.6236 - rpn_class_loss: 0.0246 - rpn_bbox_loss: 0.4319 - mrcnn_class_loss: 0.3052 - mrcnn_bbox_loss: 0.4136 - mrcnn_mask_loss: 0.4483 - val_loss: 1.7855 - val_rpn_class_loss: 0.0283 - val_rpn_bbox_loss: 0.4782 - val_mrcnn_class_loss: 0.3782 - val_mrcnn_bbox_loss: 0.4561 - val_mrcnn_mask_loss: 0.4447
Epoch 7/15
150/150 [==============================] - 198s 1s/step - loss: 1.6660 - rpn_class_loss: 0.0297 - rpn_bbox_loss: 0.3727 - mrcnn_class_loss: 0.4151 - mrcnn_bbox_loss: 0.4138 - mrcnn_mask_loss: 0.4347 - val_loss: 1.5738 - val_rpn_class_loss: 0.0204 - val_rpn_bbox_loss: 0.3539 - val_mrcnn_class_loss: 0.2837 - val_mrcnn_bbox_loss: 0.4517 - val_mrcnn_mask_loss: 0.4641
Epoch 8/15
150/150 [==============================] - 198s 1s/step - loss: 1.6270 - rpn_class_loss: 0.0264 - rpn_bbox_loss: 0.4118 - mrcnn_class_loss: 0.3484 - mrcnn_bbox_loss: 0.4087 - mrcnn_mask_loss: 0.4316 - val_loss: 1.4721 - val_rpn_class_loss: 0.0207 - val_rpn_bbox_loss: 0.4436 - val_mrcnn_class_loss: 0.2589 - val_mrcnn_bbox_loss: 0.3689 - val_mrcnn_mask_loss: 0.3800
Epoch 9/15
150/150 [==============================] - 198s 1s/step - loss: 1.5445 - rpn_class_loss: 0.0251 - rpn_bbox_loss: 0.3952 - mrcnn_class_loss: 0.3573 - mrcnn_bbox_loss: 0.3754 - mrcnn_mask_loss: 0.3914 - val_loss: 1.6586 - val_rpn_class_loss: 0.0279 - val_rpn_bbox_loss: 0.5210 - val_mrcnn_class_loss: 0.3095 - val_mrcnn_bbox_loss: 0.3879 - val_mrcnn_mask_loss: 0.4124
Epoch 10/15
150/150 [==============================] - 198s 1s/step - loss: 1.4816 - rpn_class_loss: 0.0256 - rpn_bbox_loss: 0.3714 - mrcnn_class_loss: 0.3485 - mrcnn_bbox_loss: 0.3516 - mrcnn_mask_loss: 0.3845 - val_loss: 1.6323 - val_rpn_class_loss: 0.0249 - val_rpn_bbox_loss: 0.5036 - val_mrcnn_class_loss: 0.3481 - val_mrcnn_bbox_loss: 0.3780 - val_mrcnn_mask_loss: 0.3778
Epoch 11/15
150/150 [==============================] - 198s 1s/step - loss: 1.5683 - rpn_class_loss: 0.0324 - rpn_bbox_loss: 0.4423 - mrcnn_class_loss: 0.3544 - mrcnn_bbox_loss: 0.3568 - mrcnn_mask_loss: 0.3825 - val_loss: 1.5773 - val_rpn_class_loss: 0.0229 - val_rpn_bbox_loss: 0.4872 - val_mrcnn_class_loss: 0.3083 - val_mrcnn_bbox_loss: 0.3959 - val_mrcnn_mask_loss: 0.3630
Epoch 12/15
150/150 [==============================] - 197s 1s/step - loss: 1.5057 - rpn_class_loss: 0.0286 - rpn_bbox_loss: 0.4027 - mrcnn_class_loss: 0.3458 - mrcnn_bbox_loss: 0.3623 - mrcnn_mask_loss: 0.3663 - val_loss: 1.5191 - val_rpn_class_loss: 0.0188 - val_rpn_bbox_loss: 0.3394 - val_mrcnn_class_loss: 0.3640 - val_mrcnn_bbox_loss: 0.3897 - val_mrcnn_mask_loss: 0.4072
Epoch 13/15
150/150 [==============================] - 198s 1s/step - loss: 1.4136 - rpn_class_loss: 0.0201 - rpn_bbox_loss: 0.3566 - mrcnn_class_loss: 0.3124 - mrcnn_bbox_loss: 0.3520 - mrcnn_mask_loss: 0.3725 - val_loss: 1.3404 - val_rpn_class_loss: 0.0210 - val_rpn_bbox_loss: 0.2611 - val_mrcnn_class_loss: 0.3688 - val_mrcnn_bbox_loss: 0.3533 - val_mrcnn_mask_loss: 0.3361
Epoch 14/15
150/150 [==============================] - 198s 1s/step - loss: 1.4214 - rpn_class_loss: 0.0246 - rpn_bbox_loss: 0.3375 - mrcnn_class_loss: 0.3353 - mrcnn_bbox_loss: 0.3523 - mrcnn_mask_loss: 0.3718 - val_loss: 1.5430 - val_rpn_class_loss: 0.0229 - val_rpn_bbox_loss: 0.3213 - val_mrcnn_class_loss: 0.4066 - val_mrcnn_bbox_loss: 0.3941 - val_mrcnn_mask_loss: 0.3981
Epoch 15/15
150/150 [==============================] - 197s 1s/step - loss: 1.3920 - rpn_class_loss: 0.0214 - rpn_bbox_loss: 0.3561 - mrcnn_class_loss: 0.3051 - mrcnn_bbox_loss: 0.3515 - mrcnn_mask_loss: 0.3578 - val_loss: 1.5167 - val_rpn_class_loss: 0.0251 - val_rpn_bbox_loss: 0.5400 - val_mrcnn_class_loss: 0.2456 - val_mrcnn_bbox_loss: 0.3554 - val_mrcnn_mask_loss: 0.3505
In [0]:
model_path = model.find_last()
model_path
Out[0]:
'working/logs/crowdai-food-challenge20200325T1633/mask_rcnn_crowdai-food-challenge_0015.h5'
In [0]:
class InferenceConfig(FoodChallengeConfig):
    GPU_COUNT = 1
    IMAGES_PER_GPU = 1
    NUM_CLASSES = 62  # 1 Background + 61 classes
    IMAGE_MAX_DIM=256
    IMAGE_MIN_DIM=256
    NAME = "food"
    DETECTION_MIN_CONFIDENCE=0

inference_config = InferenceConfig()
inference_config.display()
Configurations:
BACKBONE                       resnet50
BACKBONE_STRIDES               [4, 8, 16, 32, 64]
BATCH_SIZE                     1
BBOX_STD_DEV                   [0.1 0.1 0.2 0.2]
COMPUTE_BACKBONE_SHAPE         None
DETECTION_MAX_INSTANCES        100
DETECTION_MIN_CONFIDENCE       0
DETECTION_NMS_THRESHOLD        0.3
FPN_CLASSIF_FC_LAYERS_SIZE     1024
GPU_COUNT                      1
GRADIENT_CLIP_NORM             5.0
IMAGES_PER_GPU                 1
IMAGE_CHANNEL_COUNT            3
IMAGE_MAX_DIM                  256
IMAGE_META_SIZE                74
IMAGE_MIN_DIM                  256
IMAGE_MIN_SCALE                0
IMAGE_RESIZE_MODE              square
IMAGE_SHAPE                    [256 256   3]
LEARNING_MOMENTUM              0.9
LEARNING_RATE                  0.001
LOSS_WEIGHTS                   {'rpn_class_loss': 1.0, 'rpn_bbox_loss': 1.0, 'mrcnn_class_loss': 1.0, 'mrcnn_bbox_loss': 1.0, 'mrcnn_mask_loss': 1.0}
MASK_POOL_SIZE                 14
MASK_SHAPE                     [28, 28]
MAX_GT_INSTANCES               100
MEAN_PIXEL                     [123.7 116.8 103.9]
MINI_MASK_SHAPE                (56, 56)
NAME                           food
NUM_CLASSES                    62
POOL_SIZE                      7
POST_NMS_ROIS_INFERENCE        1000
POST_NMS_ROIS_TRAINING         2000
PRE_NMS_LIMIT                  6000
ROI_POSITIVE_RATIO             0.33
RPN_ANCHOR_RATIOS              [0.5, 1, 2]
RPN_ANCHOR_SCALES              (32, 64, 128, 256, 512)
RPN_ANCHOR_STRIDE              1
RPN_BBOX_STD_DEV               [0.1 0.1 0.2 0.2]
RPN_NMS_THRESHOLD              0.7
RPN_TRAIN_ANCHORS_PER_IMAGE    256
STEPS_PER_EPOCH                150
TOP_DOWN_PYRAMID_SIZE          256
TRAIN_BN                       False
TRAIN_ROIS_PER_IMAGE           200
USE_MINI_MASK                  True
USE_RPN_ROIS                   True
VALIDATION_STEPS               50
WEIGHT_DECAY                   0.0001


In [0]:
# Recreate the model in inference mode
model = modellib.MaskRCNN(mode='inference', 
                          config=inference_config,
                          model_dir=ROOT_DIR)

# Load trained weights (fill in path to trained weights here)
assert model_path != "", "Provide path to trained weights"
print("Loading weights from ", model_path)
model.load_weights(model_path, by_name=True)
In [0]:
# Show few example of ground truth vs. predictions on the validation dataset 
dataset = dataset_val
fig = plt.figure(figsize=(10, 30))

for i in range(4):

    image_id = random.choice(dataset.image_ids)
    
    original_image, image_meta, gt_class_id, gt_bbox, gt_mask =\
        modellib.load_image_gt(dataset_val, inference_config, 
                               image_id, use_mini_mask=False)
    
    print(original_image.shape)
    plt.subplot(6, 2, 2*i + 1)
    visualize.display_instances(original_image, gt_bbox, gt_mask, gt_class_id, 
                                dataset.class_names, ax=fig.axes[-1])
    
    plt.subplot(6, 2, 2*i + 2)
    results = model.detect([original_image]) #, verbose=1)
    r = results[0]
    visualize.display_instances(original_image, r['rois'], r['masks'], r['class_ids'], 
                                dataset.class_names, r['scores'], ax=fig.axes[-1])
(256, 256, 3)
(256, 256, 3)
(256, 256, 3)

*** No instances to display *** 

(256, 256, 3)
In [0]:
import json
with open('/content/data/val/annotations.json') as json_file:
    data = json.load(json_file)
In [0]:
d = {}
for x in data["categories"]:
    d[x["name"]]=x["id"]
In [0]:
id_category = [0]
for x in dataset.class_names[1:]:
    id_category.append(d[x])
#id_category
In [0]:
import tqdm
import skimage
In [0]:
files = glob.glob(os.path.join('/content/data/val/test_images/images', "*.jpg"))
_final_object = []
for file in tqdm.tqdm(files):
    images = [skimage.io.imread(file) ]
    #if(len(images)!= inference_config.IMAGES_PER_GPU):
    #    images = images + [images[-1]]*(inference_config.BATCH_SIZE - len(images))
    predictions = model.detect(images, verbose=0)
    #print(file)
    for _idx, r in enumerate(predictions):
        
            image_id = int(file.split("/")[-1].replace(".jpg",""))
            for _idx, class_id in enumerate(r["class_ids"]):
                if class_id > 0:
                    mask = r["masks"].astype(np.uint8)[:, :, _idx]
                    bbox = np.around(r["rois"][_idx], 1)
                    bbox = [float(x) for x in bbox]
                    _result = {}
                    _result["image_id"] = image_id
                    _result["category_id"] = id_category[class_id]
                    _result["score"] = float(r["scores"][_idx])
                    _mask = maskUtils.encode(np.asfortranarray(mask))
                    _mask["counts"] = _mask["counts"].decode("UTF-8")
                    _result["segmentation"] = _mask
                    _result["bbox"] = [bbox[1], bbox[0], bbox[3] - bbox[1], bbox[2] - bbox[0]]
                    _final_object.append(_result)

fp = open('/content/output.json', "w")
import json
print("Writing JSON...")
fp.write(json.dumps(_final_object))
fp.close()
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 418/418 [01:08<00:00,  6.08it/s]
Writing JSON...

In [0]:
submission_file = json.loads(open("/content/output.json").read())
len(submission_file)
In [0]:
type(submission_file)
In [0]:
import random
import json
import numpy as np
import argparse
import base64
import glob
import os
from PIL import Image

from pycocotools.coco import COCO
GROUND_TRUTH_ANNOTATION_PATH = "/content/data/val/annotations.json"
ground_truth_annotations = COCO(GROUND_TRUTH_ANNOTATION_PATH)
submission_file = json.loads(open("/content/output.json").read())
results = ground_truth_annotations.loadRes(submission_file)
cocoEval = COCOeval(ground_truth_annotations, results, 'segm')
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()
loading annotations into memory...
Done (t=0.03s)
creating index...
index created!
Loading and preparing results...
DONE (t=0.00s)
creating index...
index created!
Running per image evaluation...
Evaluate annotation type *segm*
DONE (t=0.52s).
Accumulating evaluation results...
DONE (t=0.22s).
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.059
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.096
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.062
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.020
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.061
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.094
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.094
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.094
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.034
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.097
In [0]:


This, in addition to the existing Mask RCNN baseline repo should allow you to plug and play models for easy submission and experimentation.

As an alternative to Colab, Paperspace is an amazing option. Their gradient community notebooks let you use free cloud GPU’s and CPU’s and also provide internal storage that let you save models and resume training after the deployment time expires.

Paperspace

Regards
AICrowd Team

Cannot upload to the git even git lfs is checked ... windows using git tortoise

About 4 years ago

have you setup git-lfs properly? These are the steps I used:
(check that git-lfs is setup correctly in your git configuration files)

git lfs install

track the model files, if the models are saved as model.pth for example, use the following to track all pth files

git lfs track '*.pth'

Next, you need to add .gitattributes to your git repository.

git add .gitattributes 

Now that this is all set up, you should be able add the model to the git repo by

git add .
git commit -m "commit message"
git push -u origin master

Let me know if this helped.

-Shraddhaa

Where to submit the repository link?

About 4 years ago

To submit you’ll need to create a private git repository at https://gitlab.aicrowd.com with the contents of your submission(this is where all your files need to be,along with the appropriate directory structure mentioned in the starter-kit readme), and push a git tag corresponding to the version of your repository you’d like to submit.

The starter-kit has more instructions on how you can submit. Hope this helped.

Regards,
Shraddhaa

Learning to Smell

Where to start? 5 ways to learn 2 smell!

Over 3 years ago

Hi everyone!

Open In Colab

@rohitmidha23 and me are undergrad students studying computer science, and found this challenge particularly interesting to explore the applications of ML in Chemistry. We have written a notebook that explores 5 ways to attempt this challenge. It includes baselines for

Check it out @ https://colab.research.google.com/drive/1-RedHEQSAVKUowOx2p-QoKthxayRshUa?usp=sharing

The most difficult task in this challenge is trying to get good representations of SMILES that is understandable for ML algorithms and we have tried to give examples on how that has been done in the past for these kind of tasks.

We hope that this notebook helps out other beginners like ourselves.

As always we are open to any feedback, suggestions and criticism!

If you found our work helpful, do drop us a :heart:!

Seismic Facies Identification Challenge

[Explainer]: A Noob Code-First Notebook

Over 3 years ago

A Noob Code-First Notebook

Open In Colab

The title is self-explanatory. Nothing too major, just some visualizations and a baseline model that we hope can help all those looking to start out.

Some really cool 3D visualizations for you to interact and play around with. Geologists in the community, looking to you to make more sense of the data and maybe even share some insights before the challenge ends :wink:.

Here’s a sneak peak!

Check out the code here: https://colab.research.google.com/drive/1obka8aIo5zD4eJ96_FvCNdygNhXVUWOA#scrollTo=c9R9ZyYR9gCH

Hope this helps!

πŸ“ Explained by the Community | Win 4 x DJI Mavic Drones

Over 3 years ago

A Noob Code-First Notebook

Open In Colab

The title is self-explanatory. Nothing too major, just some visualizations and a baseline model that we hope can help all those looking to start out.

Some really cool 3D visualizations for you to interact and play around with. Geologists in the community, looking to you to make more sense of the data and maybe even share some insights before the challenge ends :wink:.

Here’s a sneak peak!

Check out the code here: https://colab.research.google.com/drive/1obka8aIo5zD4eJ96_FvCNdygNhXVUWOA#scrollTo=c9R9ZyYR9gCH

Hope this helps!

Hockey Team Classification

Request to see individual submission scores

Over 3 years ago

Hey @jason_brumwell,

Would it be possible to see the score of each submission? Currently, we can only see the submission that scored the highest on the leaderboard. This would really help understand how different approaches work for this task. Would this be possible? or is there a specific reason for not showing the scores?

Regards
Shraddhaa

About the evaluation metric

Over 3 years ago

Would it be possible to know more about the evaluation metrics used for this challenge, like how the primary score and secondary score is calculated? @jason_brumwell

FOODC

Image ambiguity

Almost 4 years ago

Hi @jakub_bartczuk,

Thanks for your observations and feedback. The images in this dataset were collected from real users who track their daily food habits by taking pictures of food items they consume, and hence reflects the actual distribution of the data in the wild !

As you would expect there would be a few overlapping food items as well as some level of wrongly annotated data. Having gone through the data myself, there is a significant portion of images that can be classified as just one thing. There definitely are some exceptions as you have found. For example here is a visualization of all the images in the hard cheese class.

Some of the images have multiple food items, and hence as pointed out by you, there is significant merit in treating this as a multi-label classification problem. As a matter of fact, we plan to release a much larger version of this dataset with individual segmentations of all the different food items in each of the images, modelled as an image segmentation task. The said task would be a research challenge and not a part of the educational Blitz related initiatives. But we assure you, the nuanced data distributions and class imbalances will continue to be well represented even in the larger dataset : because it is what the real world distribution is.

At the same time, as mentioned in the forums a few times, we wanted to come up with a simplified classification problem from the original dataset as an easy-to-get-started problem for many of the community members.

We appreciate your inputs and the points you raised around the problem formulation, and are sure all of them would be well addressed when the larger dataset is released at the end of this month.

As this iteration of the AIcrowd Blitz ends, we hope we will be successful in aggregating all the activity that happened around these starter problems, and hope that we will be able to have continued engagement from community members like yourself even in the research challenges that we will organize as extensions to these problems.

Regards
Shraddhaa

ORIENTME

Colors in the Cube

Almost 4 years ago

Hey,
I do think the color is orange. You can check this discussion to see images of how the dataset was created.

AMLD 2020 - Transfer Learning for International...

Rssfete and tearth: Thank you so much

Over 4 years ago

@student Do let us know if you are attending the conference, we’d love to see you there.

Congrats and good luck!

shraddhaa_mohan has not provided any information yet.

Notebooks

Create Notebook