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 gradio as gr | |
| import numpy as np | |
| # Global variable to store the first click coordinates | |
| start_point = None | |
| def draw_bounding_box(image: np.ndarray, event: gr.SelectData) -> tuple: | |
| """ | |
| Handle click events to draw a bounding box on the image. | |
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
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| import sys | |
| # Function to print a formatted section header | |
| def print_header(msg): | |
| print("\n" + "=" * len(msg)) | |
| print(msg) | |
| print("=" * len(msg)) |
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
| Package Version | |
| ----------------------------- ----------- | |
| absl-py 2.1.0 | |
| accelerate 0.30.0 | |
| addict 2.4.0 | |
| aiofiles 23.2.1 | |
| aiohttp 3.9.5 | |
| aiosignal 1.3.1 | |
| aliyun-python-sdk-core 2.15.1 | |
| aliyun-python-sdk-kms 2.16.3 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 colorlog | |
| import logging | |
| # 创建日志记录器 | |
| logger = colorlog.getLogger(__name__) | |
| # 设置日志级别和格式 | |
| logger.setLevel(logging.DEBUG) | |
| formatter = colorlog.ColoredFormatter( | |
| "%(log_color)s%(levelname)-8s%(reset)s %(log_color)s%(asctime)s | %(blue)s%(message)s", |
We can't make this file beautiful and searchable because it's too large.
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
| n00004475,organism, being | |
| n00005787,benthos | |
| n00006024,heterotroph | |
| n00006484,cell | |
| n00007846,person, individual, someone, somebody, mortal, soul | |
| n00015388,animal, animate_being, beast, brute, creature, fauna | |
| n00017222,plant, flora, plant_life | |
| n00021265,food, nutrient | |
| n00021939,artifact, artefact | |
| n00120010,hop |
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
| """ | |
| # Anomaly Simulation for MVTecAD | |
| # Download describable textures dataset | |
| wget https://www.robots.ox.ac.uk/~vgg/data/dtd/download/dtd-r1.0.1.tar.gz | |
| # Download MVTec anomaly detection dataset | |
| wget https://www.mydrive.ch/shares/38536/3830184030e49fe74747669442f0f282/download/420938113-1629952094/mvtec_anomaly_detection.tar.xz | |
| """ | |
| import os | |
| import random |
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 math | |
| import os | |
| import random | |
| from itertools import product | |
| import numpy as np | |
| from imgaug import augmenters as iaa | |
| from PIL import Image | |
| IMG_SIZE = 600 |
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 numpy as np | |
| def voc_ap(rec, prec): | |
| # correct AP calculation | |
| # first append sentinel values at the end | |
| mrec = np.concatenate(([0.], rec, [1.])) #[0. 0.0666, 0.1333, 0.4 , 0.4666, 1.] | |
| mpre = np.concatenate(([0.], prec, [0.])) #[0. 1., 0.6666, 0.4285, 0.3043, 0.] | |
| for i in range(mpre.size - 1, 0, -1): | |
| mpre[i - 1] = np.maximum(mpre[i - 1], mpre[i]) #[1. 1. 0.6666 0.4285 0.3043 0. ] |
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 torch | |
| checkpoint = torch.load("resnet18.pth.tar") | |
| state_dict = checkpoint["state_dict"] | |
| from collections import OrderedDict | |
| new_state_dict = OrderedDict() | |
| for k, v in state_dict.items(): | |
| name = k[7:] # remove 'module.' of dataparallel |
NewerOlder