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 os | |
| from huggingface_hub import InferenceClient | |
| from typing import List, Literal, TypedDict, Callable | |
| Role = Literal["system", "user", "assistant"] | |
| class Message(TypedDict): | |
| role: Role |
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 numpy as np # version 1.16.1 and python 3.6.7 | |
| def nms_cpu_kernel(dets, scores, iou_threshold): | |
| x1 = dets[:, 0] | |
| y1 = dets[:, 1] | |
| x2 = dets[:, 2] | |
| y2 = dets[:, 3] | |
| areas = (x2 - x1) * (y2 - y1) |
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
| # Author: Vinicius Arruda | |
| # viniciusarruda.github.io | |
| # Source code modified from: https://medium.com/@stepanulyanin/implementing-grad-cam-in-pytorch-ea0937c31e82 | |
| import torch | |
| import torch.nn as nn | |
| import torch.nn.functional as F | |
| from torch.utils import data | |
| from torchvision import transforms | |
| from torchvision import datasets |
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
| EPOCH FITNESS CHROMOSOME | |
| 0 86 dktzmkeqixkmpzskjqjn | |
| 1 85 enstfgzpbwrcxoosnfbh | |
| 2 78 jetvbgqcbpceqtnnctdm | |
| 3 66 cpujjdaldsjhuuoraejn | |
| 4 55 enurcichvsoepthmckeh | |
| 5 44 enstfggohqnewnoncmkk | |
| 6 43 bosqbgigbwrculrqcmkm | |
| 7 38 enstfggohqnevqsqcmcj | |
| 8 38 enstfggohqnevqsqcmcj |
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
| EPOCH FITNESS CHROMOSOME | |
| 0 10279 [8, 6, 12, 1, 11, 9, 2, 0, 7, 5, 10, 3, 4] | |
| 1 9972 [7, 0, 2, 9, 3, 5, 11, 6, 8, 1, 4, 12, 10] | |
| 2 9972 [7, 0, 2, 9, 3, 5, 11, 6, 8, 1, 4, 12, 10] | |
| 3 9759 [9, 2, 12, 11, 1, 8, 6, 4, 10, 5, 3, 7, 0] | |
| 4 9509 [8, 6, 1, 11, 4, 10, 5, 9, 7, 0, 2, 3, 12] | |
| 5 9309 [7, 0, 2, 4, 9, 3, 5, 10, 12, 11, 1, 8, 6] | |
| 6 9161 [0, 7, 3, 2, 9, 5, 10, 11, 6, 1, 8, 12, 4] | |
| 7 9161 [0, 7, 3, 2, 9, 5, 10, 11, 6, 1, 8, 12, 4] | |
| 8 9161 [0, 7, 3, 2, 9, 5, 10, 11, 6, 1, 8, 12, 4] |
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
| city_distance = [ | |
| [ 0, 2451, 713, 1018, 1631, 1374, 2408, 213, 2571, 875, 1420, 2145, 1972], # New York | |
| [2451, 0, 1745, 1524, 831, 1240, 959, 2596, 403, 1589, 1374, 357, 579], # Los Angeles | |
| [ 713, 1745, 0, 355, 920, 803, 1737, 851, 1858, 262, 940, 1453, 1260], # Chicago | |
| [1018, 1524, 355, 0, 700, 862, 1395, 1123, 1584, 466, 1056, 1280, 987], # Minneapolis | |
| [1631, 831, 920, 700, 0, 663, 1021, 1769, 949, 796, 879, 586, 371], # Denver | |
| [1374, 1240, 803, 862, 663, 0, 1681, 1551, 1765, 547, 225, 887, 999], # Dallas | |
| [2408, 959, 1737, 1395, 1021, 1681, 0, 2493, 678, 1724, 1891, 1114, 701], # Seattle | |
| [ 213, 2596, 851, 1123, 1769, 1551, 2493, 0, 2699, 1038, 1605, 2300, 2099], # Boston | |
| [2571, 403, 1858, 1584, 949, 1765, 678, 2699, 0, 1744, 1645, 653, 600], # San Francisco |
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
| def genetic_algorithm(n): | |
| population = init_population(n) | |
| for _ in xrange(epochs): | |
| fn = fitness(population) | |
| parents = selection(n, fn) | |
| offspring = crossover(parents) | |
| offspring = mutation(offspring) | |
| population = parents + offspring | |
| return best(population) |
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
| # -*- coding: utf-8 -*- | |
| # | |
| # Author: Vinicius Ferraco Arruda | |
| # Email: viniciusferracoarruda@gmail.com | |
| # Website: viniciusarruda.github.io | |
| # | |
| import argparse | |
| from PIL import 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
| from PIL import Image | |
| import os | |
| import numpy as np | |
| def _square(img): | |
| w, h = img.size | |
| s = min(h, w) | |
| sh = (h - s)/2.0 | |
| sw = (w - s)/2.0 | |
| cropped_img = img.crop((sw, sh, sw+s, sh+s)) |