This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from Detector import Detector | |
| import io | |
| from flask import Flask, render_template, request, send_from_directory, send_file | |
| from PIL import Image | |
| import requests | |
| import os | |
| app = Flask(__name__) | |
| detector = Detector() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import cv2 as cv | |
| import json | |
| from detectron2.engine import DefaultPredictor | |
| from detectron2.config import get_cfg | |
| from detectron2.utils.visualizer import Visualizer | |
| from detectron2.utils.visualizer import ColorMode | |
| from detectron2 import model_zoo | |
| from detectron2.data import MetadataCatalog, DatasetCatalog | |
| from detectron2.modeling import build_model | |
| import torch | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import cv2 as cv | |
| import json | |
| from detectron2.engine import DefaultPredictor | |
| from detectron2.config import get_cfg | |
| from detectron2.utils.visualizer import Visualizer | |
| from detectron2.utils.visualizer import ColorMode | |
| from detectron2 import model_zoo | |
| from detectron2.data import MetadataCatalog, DatasetCatalog | |
| from detectron2.modeling import build_model | |
| import torch | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # stop containers | |
| docker stop $(docker ps -a -q) | |
| # remove containers | |
| docker rm $(docker ps -a -q) && docker rmi $(docker images | grep '^<none>' | awk '{print $3}') | |
| # build container | |
| docker build . -f Dockerfile -t detectron2 | |
| # run contrainer on port 8080 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # adapted from: https://github.com/facebookresearch/detectron2/blob/master/docker/Dockerfile | |
| FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04 | |
| ENV DEBIAN_FRONTEND noninteractive | |
| RUN apt-get update && apt-get install -y \ | |
| python3-opencv ca-certificates python3-dev git wget sudo curl && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # create a non-root user | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | {% block content %} | |
| <body> | |
| <p> Error in retrieving image </p> | |
| </body> | |
| {% endblock %} | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <!DOCTYPE html> | |
| <html lang="en"> | |
| <body> | |
| <h1 style="text-align:center;">Detectron2 Web App</h1> | |
| <br> | |
| <h2>Detectron2 Instance Segmentation</h2> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | user_name = 'userId' | |
| item_name = 'movieId' | |
| rating_name = 'rating' | |
| cols = [user_name, item_name, rating_name] | |
| data = (CollabDataBunch.from_df( | |
| ratings[cols], | |
| user_name=user_name, | |
| item_name=item_name, | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | model = EmbeddingDot(n_users, n_movies).cuda() | |
| opt = optim.SGD(model.parameters(), 1e-1, weight_decay=1e-5, momentum=0.9) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from fastai.collab import * | |
| from fastai.tabular import * | |
| user_name = 'userId' | |
| item_name = 'movieId' | |
| rating_name = 'rating' | |
| x = ratings.drop([rating_name, 'timestamp'],axis=1) | |
| y = ratings[rating_name].astype(np.float32) | |
| data = ColumnarModelData.from_data_frame(path, val_idxs, x, y, [user_name, item_name], bs=64) |