Skip to content

Instantly share code, notes, and snippets.

Avatar

Lakshay lakshay-arora

View GitHub Profile
View add_sheet.py
# add a sheet with 20 rows and 2 columns
sheet.add_worksheet(rows=20,cols=2,title='runs')
# get the instance of the second sheet
sheet_runs = sheet.get_worksheet(1)
View generate_html.py
# define function to add the image in the html file with the class name
def get_picture_html(path, tag):
image_html = """<p> {tag_name} </p> <picture> <img src= "../{path_name}" height="300" width="400"> </picture>"""
return image_html.format(tag_name=tag, path_name=path)
# define function to add the list element in the html file
def get_count_html(category, count):
count_html = """<li> {category_name} : {count_} </li>"""
return count_html.format(category_name = category, count_ = count)
View additional_updated2.py
# get directory function in get images file
def get_directory(url):
return "URL_" + str(url.replace("/","_"))
View setup_flask.py
# importing the required libaries
from flask import Flask, render_template, request, redirect, url_for
from get_images import get_images, get_path, get_directory
from get_prediction import get_prediction
from generate_html import generate_html
from torchvision import models
import json
app = Flask(__name__)
View scrape_images.py
# importing required libraries
import requests
from bs4 import BeautifulSoup
import os
import time
def get_path(url):
return "static/URL_" + str(url.replace("/","_"))
headers = {
View deploy_pytorch_1.py
# importing the required libraries
import json
import io
import glob
from PIL import Image
from torchvision import models
import torchvision.transforms as transforms
# Pass the parameter "pretrained" as "True" to use the pretrained weights:
model = models.densenet121(pretrained=True)
View pycaret_load_model.py
# load model
dt_model = classification.load_model(model_name='decision_tree_1')
View pycaret_save_model.py
# save the model
classification.save_model(classification_dt, 'decision_tree_1')
View prediction_test_pycaret.py
# read the test data
test_data_classification = pd.read_csv('datasets/loan_test_data.csv')
# make predictions
predictions = classification.predict_model(classification_dt, data=test_data_classification)
# view the predictions
predictions
View interpret_model_2.py
# interpret model : Correlation
classification.interpret_model(classification_xgb,plot='correlation')
You can’t perform that action at this time.