This file contains 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
dls.show_batch() | |
#How many categories of fruits do we have? | |
dls.c # no of categories | |
This file contains 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
```py | |
import os | |
from fastai.vision.all import * | |
from fastai.vision.widgets import * | |
# Set the base directory where Kaggle saves its data. Change this if you are on your machine. | |
root_dir = "../input/fruits/fruits-360_dataset/fruits-360/Training" | |
``` |
This file contains 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
path = Path(root_dir) # base path | |
fields = DataBlock( | |
blocks=(ImageBlock, CategoryBlock), | |
get_items=get_image_files, | |
get_y=get_parent_name, | |
splitter=RandomSplitter(valid_pct=0.2, seed=42), | |
item_tfms=RandomResizedCrop(64, min_scale=0.5), | |
batch_tfms=aug_transforms(), | |
) | |
dls = fields.dataloaders(path) |
This file contains 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 get_parent_name(x): | |
return x.parent.name |
This file contains 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
list_of_orgs = [ | |
] # Enter a list of organizations you created | |
""" | |
eg: list_of_orgs = [ | |
"backups", "image-process", "old-codes" | |
] | |
""" | |
sites = ''' | |
''' # A comma separated list of repository names | |
#eg : algos, dsa, theylia, zeus |
This file contains 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
for i, site in tqdm(enumerate(sites.split(",")), total=len(sites.split(","))): | |
site = f"https://github.com/{user_name}/{site}" | |
repo_name = str(site).split("/")[-1].strip() | |
# Go to site | |
browser.get(site+"/settings") | |
# Choose organization | |
puts = to_put[i] | |
if puts == "D": | |
browser.find_element_by_xpath( | |
'//*[@id="options_bucket"]/div[10]/ul/li[4]/details/summary').click() |
This file contains 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
sites = sites.replace(" ", "") # Just make sure it works | |
assert len(sites.split(",")) == len(to_put) | |
actions = ActionChains(browser) # Syntax for selenium to send a bunch of keypresses | |
browser.get('https://github.com/login') | |
time.sleep(1) | |
chain_actions(actions, [email, Keys.TAB, passw, Keys.TAB, Keys.ENTER]) | |
time.sleep(1) |
This file contains 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
if browser.lower() == "chrome": | |
from selenium.webdriver import Chrome | |
from selenium.webdriver.chrome.options import Options | |
opts = Options() | |
browser = Chrome(options=opts) | |
elif browser.lower() == "firefox": | |
from selenium.webdriver import Firefox | |
from selenium.webdriver.firefox.options import Options | |
opts = Options() | |
browser = Firefox(options=opts) |
This file contains 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 time | |
from selenium.webdriver.common.action_chains import ActionChains | |
from selenium.webdriver.common.keys import Keys | |
from tqdm import tqdm | |
browser = "chrome" # or firefox | |
user_name = "" # github username | |
email = "" # your login creds | |
passw = "" # your password (please please do not push this to github) |
This file contains 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
pip freeze > requirements.txt #for pip | |
conda list --export #for conda |