diff --git a/01d1a50b9ae858ac9bce7ade16fa74512f94fd b/01d1a50b9ae858ac9bce7ade16fa74512f94fd new file mode 100644 index 0000000000000000000000000000000000000000..78bad6df93c315825e24172f074e417facc0cdeb Binary files /dev/null and b/01d1a50b9ae858ac9bce7ade16fa74512f94fd differ diff --git a/0ba5f24071de74933fb3dcbafc1f8c1c1cbd12 b/0ba5f24071de74933fb3dcbafc1f8c1c1cbd12 new file mode 100644 index 0000000000000000000000000000000000000000..03ff7e10a828edc13e14004167dc1ffb369315d0 Binary files /dev/null and b/0ba5f24071de74933fb3dcbafc1f8c1c1cbd12 differ diff --git a/1240b98ed69c04a3e9d59db645ef8e97edc12d b/1240b98ed69c04a3e9d59db645ef8e97edc12d new file mode 100644 index 0000000000000000000000000000000000000000..4de53af50b2f4062317a5c5f4c8e84002d01626b Binary files /dev/null and b/1240b98ed69c04a3e9d59db645ef8e97edc12d differ diff --git a/142db7d0bba5750cbf9d2f56e9bcad443ea6b5 b/142db7d0bba5750cbf9d2f56e9bcad443ea6b5 new file mode 100644 index 0000000000000000000000000000000000000000..dcfe8836b1825eb83b28e01ab924eda0e2763cc2 Binary files /dev/null and b/142db7d0bba5750cbf9d2f56e9bcad443ea6b5 differ diff --git a/1b251536fa09d28d36b8f7476f6453a7667628 b/1b251536fa09d28d36b8f7476f6453a7667628 new file mode 100644 index 0000000000000000000000000000000000000000..a7c7632ec2a32d194649201fdc4b6b2be24ba4a6 --- /dev/null +++ b/1b251536fa09d28d36b8f7476f6453a7667628 @@ -0,0 +1,3 @@ +xK +1D]$ zL@ho`n`A*5\d@:ow46Ge&%(Rg,m^`g<^-q+0y \t~ +Va|Q?.9 \ No newline at end of file diff --git a/2d38bf3c6a186c78eae26361deb7aae51b1a8c b/2d38bf3c6a186c78eae26361deb7aae51b1a8c new file mode 100644 index 0000000000000000000000000000000000000000..1f919e9b45f6a5d7502c0138be5107076d724fde Binary files /dev/null and b/2d38bf3c6a186c78eae26361deb7aae51b1a8c differ diff --git a/338539cc975ea9ce37941545cc031d4e94fcd0 b/338539cc975ea9ce37941545cc031d4e94fcd0 new file mode 100644 index 0000000000000000000000000000000000000000..2e73730ec8d515eb1e3f800e50c6089bb0f088e3 Binary files /dev/null and b/338539cc975ea9ce37941545cc031d4e94fcd0 differ diff --git a/344aac8c09253b3b630fb776ae94478aa0275b b/344aac8c09253b3b630fb776ae94478aa0275b new file mode 100644 index 0000000000000000000000000000000000000000..9f125cc2655c4fddcf16576fb0da4bdb4658f1d9 --- /dev/null +++ b/344aac8c09253b3b630fb776ae94478aa0275b @@ -0,0 +1,2 @@ +x10 E9EHB %SB$JOO| /bvU6KCTkR0JMmd]H(@WQ +[#+ Nq=En+It9,Q `n[F4/w9[Id7Mǣ1G` ۾(V(?V&p| ,(zzSR2Ă \ No newline at end of file diff --git a/40841ac768b5e51df9d30213a589ffe6439f7d b/40841ac768b5e51df9d30213a589ffe6439f7d new file mode 100644 index 0000000000000000000000000000000000000000..bd00aa562728886a382a4d723c4108c434518f35 --- /dev/null +++ b/40841ac768b5e51df9d30213a589ffe6439f7d @@ -0,0 +1,5 @@ +x5M +0W-mW +~u[Wncoq +!$]l1PB>^Q 䌑U]D\ZU@,[.!+=L +';왠wْ1gD<=a.ɵ s4GGv9ǭLu>3D \ No newline at end of file diff --git a/65ab4c4bd40cae9973417b5b8d4c0c1edd7fc7 b/65ab4c4bd40cae9973417b5b8d4c0c1edd7fc7 new file mode 100644 index 0000000000000000000000000000000000000000..c756a02d41f991e842b607f091b67890d3747cd5 Binary files /dev/null and b/65ab4c4bd40cae9973417b5b8d4c0c1edd7fc7 differ diff --git a/6ee8951c7546c7bc5876304b0f287036ad5361 b/6ee8951c7546c7bc5876304b0f287036ad5361 new file mode 100644 index 0000000000000000000000000000000000000000..37bf19dbe76ad28aaa2e25d9b02f332b7d2a92ef --- /dev/null +++ b/6ee8951c7546c7bc5876304b0f287036ad5361 @@ -0,0 +1,2 @@ +x5 +0E]W ՐD7ٺU 4Mi&ҿ7Xa`=(?}J]`B㦔dIx:iUJo7.Q"" MB5F(eGS.ܭ? 񈏄$ޕkvEr[Ǻ#RH \ No newline at end of file diff --git a/7e1f7b4564f1249151b684110e5ae429969e82 b/7e1f7b4564f1249151b684110e5ae429969e82 new file mode 100644 index 0000000000000000000000000000000000000000..e8b5935ab1bd4694e61fcefc6ec12f20f5536a8c Binary files /dev/null and b/7e1f7b4564f1249151b684110e5ae429969e82 differ diff --git a/7fb3351b345190fa253cc10972815b04e223a5 b/7fb3351b345190fa253cc10972815b04e223a5 new file mode 100644 index 0000000000000000000000000000000000000000..bac77b717aa9ca830d0529ce316f53409eb9734d Binary files /dev/null and b/7fb3351b345190fa253cc10972815b04e223a5 differ diff --git a/82015897d315ee0c1caf9a7c6afc88e9c8b7e7 b/82015897d315ee0c1caf9a7c6afc88e9c8b7e7 new file mode 100644 index 0000000000000000000000000000000000000000..2ff9ceed6dc0aa125963d2ae13fe85d99f7d2d74 Binary files /dev/null and b/82015897d315ee0c1caf9a7c6afc88e9c8b7e7 differ diff --git a/99da7d986114fd50a3067f9845aca74cb976bc b/99da7d986114fd50a3067f9845aca74cb976bc new file mode 100644 index 0000000000000000000000000000000000000000..2745f071a61534672711233f6b234af9f0070597 Binary files /dev/null and b/99da7d986114fd50a3067f9845aca74cb976bc differ diff --git a/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 b/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 new file mode 100644 index 0000000000000000000000000000000000000000..711223894375fe1186ac5bfffdc48fb1fa1e65cc Binary files /dev/null and b/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 differ diff --git a/Base-RCNN-FPN.yaml b/Base-RCNN-FPN.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a7b04af489e5e04b3bff84cdaee0263a27dbfc27 --- /dev/null +++ b/Base-RCNN-FPN.yaml @@ -0,0 +1,18 @@ +MODEL: + META_ARCHITECTURE: "GeneralizedRCNN" + RPN: + PRE_NMS_TOPK_TEST: 6000 + POST_NMS_TOPK_TEST: 1000 + ROI_HEADS: + NAME: "Res5ROIHeads" +DATASETS: + TRAIN: ("coco_2017_train",) + TEST: ("coco_2017_val",) +SOLVER: + IMS_PER_BATCH: 16 + BASE_LR: 0.02 + STEPS: (60000, 80000) + MAX_ITER: 90000 +INPUT: + MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) +VERSION: 2 \ No newline at end of file diff --git a/COMMIT_EDITMSG b/COMMIT_EDITMSG new file mode 100644 index 0000000000000000000000000000000000000000..4749e00ca75cce81df3f286f9dbce7e6cf0ee56d --- /dev/null +++ b/COMMIT_EDITMSG @@ -0,0 +1 @@ +update dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1c1240b98ed69c04a3e9d59db645ef8e97edc12d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,60 @@ +FROM nvidia/cuda:11.1.1-cudnn8-devel-ubuntu18.04 +# use an older system (18.04) to avoid opencv incompatibility (issue#3524) + +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update && apt-get install -y \ + python3-opencv ca-certificates python3-dev git wget sudo ninja-build +RUN ln -sv /usr/bin/python3 /usr/bin/python + +# create a non-root user +ARG USER_ID=1000 +RUN useradd -m --no-log-init --system --uid ${USER_ID} appuser -g sudo +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +USER appuser +WORKDIR /home/appuser + +ENV PATH="/home/appuser/.local/bin:${PATH}" +RUN wget https://bootstrap.pypa.io/pip/3.6/get-pip.py && \ + python3 get-pip.py --user && \ + rm get-pip.py + +# install dependencies +# See https://pytorch.org/ for other options if you use a different version of CUDA +RUN pip install --user tensorboard cmake onnx # cmake from apt-get is too old +RUN pip install --user torch==1.10 torchvision==0.11.1 -f https://download.pytorch.org/whl/cu111/torch_stable.html + +RUN pip install --user 'git+https://github.com/facebookresearch/fvcore' +# install detectron2 +RUN git clone https://github.com/facebookresearch/detectron2 detectron2_repo +# set FORCE_CUDA because during `docker build` cuda is not accessible +ENV FORCE_CUDA="1" +# This will by default build detectron2 for all common cuda architectures and take a lot more time, +# because inside `docker build`, there is no way to tell which architecture will be used. +ARG TORCH_CUDA_ARCH_LIST="Kepler;Kepler+Tesla;Maxwell;Maxwell+Tegra;Pascal;Volta;Turing" +ENV TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST}" + +RUN pip install --user -e detectron2_repo + +# Set a fixed model cache directory. +ENV FVCORE_CACHE="/tmp" +WORKDIR /home/appuser/detectron2_repo + +# run detectron2 under user "appuser": +# wget http://images.cocodataset.org/val2017/000000439715.jpg -O input.jpg +# python3 demo/demo.py \ + #--config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \ + #--input input.jpg --output outputs/ \ + #--opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl +FROM python:3.9 + +RUN useradd -m -u 1000 user +USER user +ENV PATH="/home/user/.local/bin:$PATH" + +WORKDIR /app + +COPY --chown=user ./requirements.txt requirements.txt +RUN pip install --no-cache-dir --upgrade -r requirements.txt + +COPY --chown=user . /app +CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] diff --git a/HEAD b/HEAD new file mode 100644 index 0000000000000000000000000000000000000000..4b0a87595873e6007ce078a8631d3a757097d1a0 --- /dev/null +++ b/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/main diff --git a/Procfile b/Procfile new file mode 100644 index 0000000000000000000000000000000000000000..8001d1a50b9ae858ac9bce7ade16fa74512f94fd --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn app:app \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000000000000000000000000000000000000..b5142db7d0bba5750cbf9d2f56e9bcad443ea6b5 --- /dev/null +++ b/app.py @@ -0,0 +1,109 @@ +from flask import Flask, request, jsonify, render_template +from detectron2main.config import get_cfg +from detectron2main.engine import DefaultPredictor +from detectron2main.data import MetadataCatalog +from detectron2main.utils.visualizer import Visualizer, ColorMode +import numpy as np +from PIL import Image +import io +import os +import requests +import gdown + +# Initialize Flask app +app = Flask(__name__) +cfg = None +# Google Drive file URL +GDRIVE_MODEL_URL = "https://drive.google.com/uc?id=18aEDo-kWOBhg8mAhnbpFkuM6bmmrBH4E" # Replace 'your-file-id' with the actual file ID from Google Drive +LOCAL_MODEL_PATH = "model_final.pth" +def download_file_from_google_drive(id, destination): + gdown.download(GDRIVE_MODEL_URL, LOCAL_MODEL_PATH, quiet=False) + + +file_id = '18aEDo-kWOBhg8mAhnbpFkuM6bmmrBH4E' +destination = 'model_final.pth' +download_file_from_google_drive(file_id, destination) + +# Download model from Google Drive if not already present locally +def download_model(): + if not os.path.exists(LOCAL_MODEL_PATH): + response = requests.get(GDRIVE_MODEL_URL, stream=True) + if response.status_code == 200: + with open(LOCAL_MODEL_PATH, 'wb') as f: + f.write(response.content) + else: + raise Exception(f"Failed to download model from Google Drive: {response.status_code}") + +# Configuration and model setup +def setup_model(model_path): + global cfg + cfg = get_cfg() + cfg.merge_from_file("config.yaml") # Update with the config file path + cfg.MODEL.WEIGHTS = model_path + cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5 + cfg.MODEL.DEVICE = "cpu" # Use "cuda" for GPU + return DefaultPredictor(cfg) + +# Ensure model is available +predictor = setup_model(LOCAL_MODEL_PATH) + +# Define expected parts and costs +expected_parts = ['headlamp', 'rear_bumper', 'door', 'hood', 'front_bumper'] +cost_dict = { + 'headlamp': 300, + 'rear_bumper': 250, + 'door': 200, + 'hood': 220, + 'front_bumper': 250, + 'other': 150 +} + +@app.route('/') +def home(): + return render_template('index.html') + +@app.route('/upload', methods=['POST']) +def upload(): + if 'file' not in request.files: + return jsonify({"error": "No file uploaded"}), 400 + + file = request.files['file'] + if file.filename == '': + return jsonify({"error": "No file selected"}), 400 + + # Load image + image = Image.open(file).convert("RGB") + image_np = np.array(image) + + # Run model prediction + outputs = predictor(image_np) + instances = outputs["instances"].to("cpu") + class_names = MetadataCatalog.get(cfg.DATASETS.TEST[0]).thing_classes + + # Initialize total cost + total_cost = 0 + damage_details = [] + + for j in range(len(instances)): + class_id = instances.pred_classes[j].item() + damaged_part = class_names[class_id] if class_id < len(class_names) else 'unknown' + if damaged_part not in expected_parts: + damaged_part = 'other' + + repair_cost = cost_dict.get(damaged_part, cost_dict['other']) + total_cost += repair_cost + + damage_details.append({ + 'part': damaged_part, + 'cost_usd': repair_cost + }) + + response = { + "damages": damage_details, + "total_cost": total_cost + } + + return jsonify(response) + +if __name__ == '__main__': + app.run(debug=True) diff --git a/applypatch-msg.sample b/applypatch-msg.sample new file mode 100755 index 0000000000000000000000000000000000000000..a5d7b84a673458d14d9aab082183a1968c2c7492 --- /dev/null +++ b/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/b04af489e5e04b3bff84cdaee0263a27dbfc27 b/b04af489e5e04b3bff84cdaee0263a27dbfc27 new file mode 100644 index 0000000000000000000000000000000000000000..2147e95e7408622c0c4a7942e2f11690d4454cfc Binary files /dev/null and b/b04af489e5e04b3bff84cdaee0263a27dbfc27 differ diff --git a/b4ed774368af89d654c9f01850d769e6cf9f52 b/b4ed774368af89d654c9f01850d769e6cf9f52 new file mode 100644 index 0000000000000000000000000000000000000000..8b05e3f53aee26109a76bc63ab2763e8dcd7c1c7 Binary files /dev/null and b/b4ed774368af89d654c9f01850d769e6cf9f52 differ diff --git a/b64513a3a8c89484e90c1ce7d6107205dfa2bb b/b64513a3a8c89484e90c1ce7d6107205dfa2bb new file mode 100644 index 0000000000000000000000000000000000000000..5f5ebee2025a89abcd40a8ccc80fea1b860ad651 Binary files /dev/null and b/b64513a3a8c89484e90c1ce7d6107205dfa2bb differ diff --git a/bdf7525023a228fbbd08bd7d70506adad8615a b/bdf7525023a228fbbd08bd7d70506adad8615a new file mode 100644 index 0000000000000000000000000000000000000000..42afe56da98929fd40b618d450788cdf73443053 Binary files /dev/null and b/bdf7525023a228fbbd08bd7d70506adad8615a differ diff --git a/c4a86461311423cae31efe9bdc20de13e6472f b/c4a86461311423cae31efe9bdc20de13e6472f new file mode 100644 index 0000000000000000000000000000000000000000..d00c2510e07e42c85b54733674be639a3b3e66e3 --- /dev/null +++ b/c4a86461311423cae31efe9bdc20de13e6472f @@ -0,0 +1 @@ +x=M0aS4`" +*g q<=L@@V+qO/!rȗԮiKW8*awEbk-'J{yZ'F}Z#O&+Z+s*TTPilt#@VX5-TnPaX9 ņgCP \ No newline at end of file diff --git a/carDamageDetectionFinal b/carDamageDetectionFinal new file mode 160000 index 0000000000000000000000000000000000000000..c07fb3351b345190fa253cc10972815b04e223a5 --- /dev/null +++ b/carDamageDetectionFinal @@ -0,0 +1 @@ +Subproject commit c07fb3351b345190fa253cc10972815b04e223a5 diff --git a/commit-msg.sample b/commit-msg.sample new file mode 100755 index 0000000000000000000000000000000000000000..b58d1184a9d43a39c0d95f32453efc78581877d6 --- /dev/null +++ b/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/config b/config new file mode 100644 index 0000000000000000000000000000000000000000..6991be39365f9c6313c8b005a5cbfff8165d6a5f --- /dev/null +++ b/config @@ -0,0 +1,11 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true +[remote "origin"] + url = https://huggingface.co/spaces/reidddd/carDamageDetection + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "main"] + remote = origin + merge = refs/heads/main diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3be98358175e37113dc547068ceb67a9cd7e9865 --- /dev/null +++ b/config.yaml @@ -0,0 +1,9 @@ +_BASE_: "Base-RCNN-FPN.yaml" +MODEL: + WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" + MASK_ON: True + RESNETS: + DEPTH: 50 +SOLVER: + STEPS: (210000, 250000) + MAX_ITER: 270000 \ No newline at end of file diff --git a/deploy.Dockerfile b/deploy.Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..30b4ed774368af89d654c9f01850d769e6cf9f52 --- /dev/null +++ b/deploy.Dockerfile @@ -0,0 +1,32 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# This file defines a container that compiles the C++ examples of detectron2. +# See docker/README.md for usage. + +# Depends on the image produced by "./Dockerfile" +FROM detectron2:v0 + +USER appuser +ENV HOME=/home/appuser +WORKDIR $HOME + +# Let torchvision find libtorch +ENV CMAKE_PREFIX_PATH=$HOME/.local/lib/python3.6/site-packages/torch/ + +RUN sudo apt-get update && sudo apt-get install libopencv-dev --yes + +# install libtorchvision +RUN git clone --branch v0.11.1 https://github.com/pytorch/vision/ +RUN mkdir vision/build && cd vision/build && \ + cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/.local -DCMAKE_BUILD_TYPE=Release -DWITH_CUDA=on -DTORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST && \ + make -j && make install + +# make our installation take effect +ENV CPATH=$HOME/.local/include \ + LIBRARY_PATH=$HOME/.local/lib \ + LD_LIBRARY_PATH=$HOME/.local/lib + + +# build C++ examples of detectron2 +RUN cd detectron2_repo/tools/deploy && mkdir build && cd build && \ + cmake -DTORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST .. && make +# binaries will be available under tools/deploy/build diff --git a/description b/description new file mode 100644 index 0000000000000000000000000000000000000000..498b267a8c7812490d6479839c5577eaaec79d62 --- /dev/null +++ b/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6665ab4c4bd40cae9973417b5b8d4c0c1edd7fc7 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,26 @@ +version: "2.3" +services: + detectron2: + build: + context: . + dockerfile: Dockerfile + args: + USER_ID: ${USER_ID:-1000} + deploy: + resources: + reservations: + devices: + - capabilities: + - gpu + shm_size: "8gb" + ulimits: + memlock: -1 + stack: 67108864 + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix:ro + environment: + - DISPLAY=$DISPLAY + - NVIDIA_VISIBLE_DEVICES=all + # Uncomment with proper source to access webcam from docker + # devices: + # - /dev/video0:/dev/video0 diff --git a/e0060b2b78b26e4cef9631a04e84db4eb2c567 b/e0060b2b78b26e4cef9631a04e84db4eb2c567 new file mode 100644 index 0000000000000000000000000000000000000000..0b5272a433a3a74967792c552b592b0f42ddeb1b Binary files /dev/null and b/e0060b2b78b26e4cef9631a04e84db4eb2c567 differ diff --git a/e251e270498f1aed0bd37ea8b7cd1df50317e5 b/e251e270498f1aed0bd37ea8b7cd1df50317e5 new file mode 100644 index 0000000000000000000000000000000000000000..d0216e23b6651c9351ccaa5196c84c93b281e419 Binary files /dev/null and b/e251e270498f1aed0bd37ea8b7cd1df50317e5 differ diff --git a/e98358175e37113dc547068ceb67a9cd7e9865 b/e98358175e37113dc547068ceb67a9cd7e9865 new file mode 100644 index 0000000000000000000000000000000000000000..ea2841822ed35846459545b5fd833a97511ec64a --- /dev/null +++ b/e98358175e37113dc547068ceb67a9cd7e9865 @@ -0,0 +1 @@ +x0E]/41!@4mH օom~j!U&7T8Jܯz۪  nfi +4cTWqx̉|4*᧦&Q&3 6(c2LE -^g̖ LͧuFnkSpt?<4@ \ No newline at end of file diff --git a/exclude b/exclude new file mode 100644 index 0000000000000000000000000000000000000000..a5196d1be8fb59edf8062bef36d3a602e0812139 --- /dev/null +++ b/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/f9e8490251dbc56e631a22442c501537ca0113 b/f9e8490251dbc56e631a22442c501537ca0113 new file mode 100644 index 0000000000000000000000000000000000000000..0a8317397afdca99e0a6dc668f6ef8a79205de27 Binary files /dev/null and b/f9e8490251dbc56e631a22442c501537ca0113 differ diff --git a/fsmonitor-watchman.sample b/fsmonitor-watchman.sample new file mode 100755 index 0000000000000000000000000000000000000000..23e856f5deeb7f564afc22f2beed54449c2d3afb --- /dev/null +++ b/fsmonitor-watchman.sample @@ -0,0 +1,174 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 2) and last update token +# formatted as a string and outputs to stdout a new update token and +# all files that have been modified since the update token. Paths must +# be relative to the root of the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $last_update_token) = @ARGV; + +# Uncomment for debugging +# print STDERR "$0 $version $last_update_token\n"; + +# Check the hook interface version +if ($version ne 2) { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree = get_working_dir(); + +my $retry = 1; + +my $json_pkg; +eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; +} or do { + require JSON::PP; + $json_pkg = "JSON::PP"; +}; + +launch_watchman(); + +sub launch_watchman { + my $o = watchman_query(); + if (is_work_tree_watched($o)) { + output_result($o->{clock}, @{$o->{files}}); + } +} + +sub output_result { + my ($clockid, @files) = @_; + + # Uncomment for debugging watchman output + # open (my $fh, ">", ".git/watchman-output.out"); + # binmode $fh, ":utf8"; + # print $fh "$clockid\n@files\n"; + # close $fh; + + binmode STDOUT, ":utf8"; + print $clockid; + print "\0"; + local $, = "\0"; + print @files; +} + +sub watchman_clock { + my $response = qx/watchman clock "$git_work_tree"/; + die "Failed to get clock id on '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + return $json_pkg->new->utf8->decode($response); +} + +sub watchman_query { + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $last_update_token but not from the .git folder. + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + my $last_update_line = ""; + if (substr($last_update_token, 0, 1) eq "c") { + $last_update_token = "\"$last_update_token\""; + $last_update_line = qq[\n"since": $last_update_token,]; + } + my $query = <<" END"; + ["query", "$git_work_tree", {$last_update_line + "fields": ["name"], + "expression": ["not", ["dirname", ".git"]] + }] + END + + # Uncomment for debugging the watchman query + # open (my $fh, ">", ".git/watchman-query.json"); + # print $fh $query; + # close $fh; + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + # Uncomment for debugging the watch response + # open ($fh, ">", ".git/watchman-response.json"); + # print $fh $response; + # close $fh; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + return $json_pkg->new->utf8->decode($response); +} + +sub is_work_tree_watched { + my ($output) = @_; + my $error = $output->{error}; + if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) { + $retry--; + my $response = qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + $output = $json_pkg->new->utf8->decode($response); + $error = $output->{error}; + die "Watchman: $error.\n" . + "Falling back to scanning...\n" if $error; + + # Uncomment for debugging watchman output + # open (my $fh, ">", ".git/watchman-output.out"); + # close $fh; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + my $o = watchman_clock(); + $error = $output->{error}; + + die "Watchman: $error.\n" . + "Falling back to scanning...\n" if $error; + + output_result($o->{clock}, ("/")); + $last_update_token = $o->{clock}; + + eval { launch_watchman() }; + return 0; + } + + die "Watchman: $error.\n" . + "Falling back to scanning...\n" if $error; + + return 1; +} + +sub get_working_dir { + my $working_dir; + if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $working_dir = Win32::GetCwd(); + $working_dir =~ tr/\\/\//; + } else { + require Cwd; + $working_dir = Cwd::cwd(); + } + + return $working_dir; +} diff --git a/index b/index new file mode 100644 index 0000000000000000000000000000000000000000..68d6e844eeb5bf7464509ee4598f7d5db6450b6a Binary files /dev/null and b/index differ diff --git a/index.html b/index.html new file mode 100644 index 0000000000000000000000000000000000000000..442d38bf3c6a186c78eae26361deb7aae51b1a8c --- /dev/null +++ b/index.html @@ -0,0 +1,91 @@ + + + + + + Upload File + + + +

Vehicle Damage Detection

+
+ + +

+ Image Preview +

+ +
+

+ + + + \ No newline at end of file diff --git a/install_detectron2.sh b/install_detectron2.sh new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/kaggle.json b/kaggle.json new file mode 100644 index 0000000000000000000000000000000000000000..f099da7d986114fd50a3067f9845aca74cb976bc --- /dev/null +++ b/kaggle.json @@ -0,0 +1 @@ +{"username":"reiddson","key":"c0103af93ef7241309fc2308824981e0"} \ No newline at end of file diff --git a/kaggle.json:Zone.Identifier b/kaggle.json:Zone.Identifier new file mode 100644 index 0000000000000000000000000000000000000000..7b338539cc975ea9ce37941545cc031d4e94fcd0 --- /dev/null +++ b/kaggle.json:Zone.Identifier @@ -0,0 +1,3 @@ +[ZoneTransfer] +ZoneId=3 +HostUrl=https://www.kaggle.com/ diff --git a/main b/main new file mode 100644 index 0000000000000000000000000000000000000000..730e95b8025f37d1489be987c736c7442cb81e91 --- /dev/null +++ b/main @@ -0,0 +1 @@ +e0b64513a3a8c89484e90c1ce7d6107205dfa2bb diff --git a/master b/master new file mode 100644 index 0000000000000000000000000000000000000000..f37869565c1c586431b9bf80eba822735b9b722c --- /dev/null +++ b/master @@ -0,0 +1 @@ +c07fb3351b345190fa253cc10972815b04e223a5 diff --git a/packed-refs b/packed-refs new file mode 100644 index 0000000000000000000000000000000000000000..59790844d5caee3372a30a38df08ba1d51e869ea --- /dev/null +++ b/packed-refs @@ -0,0 +1,3 @@ +# pack-refs with: peeled fully-peeled sorted +e0b64513a3a8c89484e90c1ce7d6107205dfa2bb refs/remotes/origin/main +c07fb3351b345190fa253cc10972815b04e223a5 refs/remotes/origin/master diff --git a/post-update.sample b/post-update.sample new file mode 100755 index 0000000000000000000000000000000000000000..ec17ec1939b7c3e86b7cb6c0c4de6b0818a7e75e --- /dev/null +++ b/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/pre-applypatch.sample b/pre-applypatch.sample new file mode 100755 index 0000000000000000000000000000000000000000..4142082bcb939bbc17985a69ba748491ac6b62a5 --- /dev/null +++ b/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/pre-commit.sample b/pre-commit.sample new file mode 100755 index 0000000000000000000000000000000000000000..e144712c85c055bcf3248ab342592b440a477062 --- /dev/null +++ b/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --type=bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/pre-merge-commit.sample b/pre-merge-commit.sample new file mode 100755 index 0000000000000000000000000000000000000000..399eab1924e39da570b389b0bef1ca713b3b05c3 --- /dev/null +++ b/pre-merge-commit.sample @@ -0,0 +1,13 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git merge" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message to +# stderr if it wants to stop the merge commit. +# +# To enable this hook, rename this file to "pre-merge-commit". + +. git-sh-setup +test -x "$GIT_DIR/hooks/pre-commit" && + exec "$GIT_DIR/hooks/pre-commit" +: diff --git a/pre-push.sample b/pre-push.sample new file mode 100755 index 0000000000000000000000000000000000000000..4ce688d32b7532862767345f2b991ae856f7d4a8 --- /dev/null +++ b/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +zero=$(git hash-object --stdin &2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/pre-rebase.sample b/pre-rebase.sample new file mode 100755 index 0000000000000000000000000000000000000000..6cbef5c370d8c3486ca85423dd70440c5e0a2aa2 --- /dev/null +++ b/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/pre-receive.sample b/pre-receive.sample new file mode 100755 index 0000000000000000000000000000000000000000..a1fd29ec14823d8bc4a8d1a2cfe35451580f5118 --- /dev/null +++ b/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/prepare-commit-msg.sample b/prepare-commit-msg.sample new file mode 100755 index 0000000000000000000000000000000000000000..10fa14c5ab0134436e2ae435138bf921eb477c60 --- /dev/null +++ b/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/push-to-checkout.sample b/push-to-checkout.sample new file mode 100755 index 0000000000000000000000000000000000000000..af5a0c0018b5e9c04b56ac52f21b4d28f48d99ea --- /dev/null +++ b/push-to-checkout.sample @@ -0,0 +1,78 @@ +#!/bin/sh + +# An example hook script to update a checked-out tree on a git push. +# +# This hook is invoked by git-receive-pack(1) when it reacts to git +# push and updates reference(s) in its repository, and when the push +# tries to update the branch that is currently checked out and the +# receive.denyCurrentBranch configuration variable is set to +# updateInstead. +# +# By default, such a push is refused if the working tree and the index +# of the remote repository has any difference from the currently +# checked out commit; when both the working tree and the index match +# the current commit, they are updated to match the newly pushed tip +# of the branch. This hook is to be used to override the default +# behaviour; however the code below reimplements the default behaviour +# as a starting point for convenient modification. +# +# The hook receives the commit with which the tip of the current +# branch is going to be updated: +commit=$1 + +# It can exit with a non-zero status to refuse the push (when it does +# so, it must not modify the index or the working tree). +die () { + echo >&2 "$*" + exit 1 +} + +# Or it can make any necessary changes to the working tree and to the +# index to bring them to the desired state when the tip of the current +# branch is updated to the new commit, and exit with a zero status. +# +# For example, the hook can simply run git read-tree -u -m HEAD "$1" +# in order to emulate git fetch that is run in the reverse direction +# with git push, as the two-tree form of git read-tree -u -m is +# essentially the same as git switch or git checkout that switches +# branches while keeping the local changes in the working tree that do +# not interfere with the difference between the branches. + +# The below is a more-or-less exact translation to shell of the C code +# for the default behaviour for git's push-to-checkout hook defined in +# the push_to_deploy() function in builtin/receive-pack.c. +# +# Note that the hook will be executed from the repository directory, +# not from the working tree, so if you want to perform operations on +# the working tree, you will have to adapt your code accordingly, e.g. +# by adding "cd .." or using relative paths. + +if ! git update-index -q --ignore-submodules --refresh +then + die "Up-to-date check failed" +fi + +if ! git diff-files --quiet --ignore-submodules -- +then + die "Working directory has unstaged changes" +fi + +# This is a rough translation of: +# +# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX +if git cat-file -e HEAD 2>/dev/null +then + head=HEAD +else + head=$(git hash-object -t tree --stdin &2 + exit 1 +} + +unset GIT_DIR GIT_WORK_TREE +cd "$worktree" && + +if grep -q "^diff --git " "$1" +then + validate_patch "$1" +else + validate_cover_letter "$1" +fi && + +if test "$GIT_SENDEMAIL_FILE_COUNTER" = "$GIT_SENDEMAIL_FILE_TOTAL" +then + git config --unset-all sendemail.validateWorktree && + trap 'git worktree remove -ff "$worktree"' EXIT && + validate_series +fi diff --git a/testKaggle.py b/testKaggle.py new file mode 100644 index 0000000000000000000000000000000000000000..d8e251e270498f1aed0bd37ea8b7cd1df50317e5 --- /dev/null +++ b/testKaggle.py @@ -0,0 +1 @@ +import kaggle \ No newline at end of file diff --git a/update.sample b/update.sample new file mode 100755 index 0000000000000000000000000000000000000000..c4d426bc6ee9430ee7813263ce6d5da7ec78c3c6 --- /dev/null +++ b/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --type=bool hooks.allowunannotated) +allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch) +denycreatebranch=$(git config --type=bool hooks.denycreatebranch) +allowdeletetag=$(git config --type=bool hooks.allowdeletetag) +allowmodifytag=$(git config --type=bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero=$(git hash-object --stdin &2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0