tonyassi's picture
Upload folder using huggingface_hub
c11ba2c verified
metadata
license: apache-2.0
base_model: google/vit-base-patch16-224
tags:
  - Image Regression
datasets:
  - tonyassi/tony__assi-ig-ds200
metrics:
  - accuracy
model-index:
  - name: tony__assi-ig-prediction200
    results: []

tony__assi-ig-prediction200

IG Prediction

This model was trained with IGPrediction. It predicts how many likes an image will get.

from IGPredict import predict_ig
predict_ig(repo_id='tonyassi/tony__assi-ig-prediction200',image_path='image.jpg')

Dataset

Dataset: tonyassi/tony__assi-ig-ds200
Value Column:
Train Test Split: 0.2


Training

Base Model: google/vit-base-patch16-224
Epochs: 20
Learning Rate: 0.0001


Usage

Download

git clone https://github.com/TonyAssi/IGPrediction.git
cd IGPrediction

Installation

pip install -r requirements.txt

Import

from IGPredict import ig_download, upload_dataset, train_ig_model, upload_ig_model, predict_ig

Download Instagram Images

  • username Instagram username
  • num_images maximum number of images to download
ig_download(username='instagarm_username', num_images=100)

Instagram images will be downloaded to './images' folder, each one named like so "index-likes.jpg". E.g. "3-17.jpg" is the third image and has 17 likes.

Upload Dataset

  • dataset_name name of dataset to be uploaded
  • token go here to create a new πŸ€— token
upload_dataset(dataset_name='tonyassi/tony__assi-ig-ds200', token='YOUR_HF_TOKEN')

Go to your πŸ€— profile to find your uploaded dataset, it should look similar to tonyassi/tony__assi-ig-ds.

Train Model

  • dataset_id πŸ€— dataset id
  • test_split test split of the train/test split
  • num_train_epochs training epochs
  • learning_rate learning rate
train_ig_model(dataset_id='tonyassi/tony__assi-ig-ds200',
               test_split=0.2,
               num_train_epochs=20,
               learning_rate=0.0001)

The trainer will save the checkpoints in the 'results' folder. The model.safetensors are the trained weights you'll use for inference (predicton).

Upload Model

This function will upload your model to the πŸ€— Hub.

  • model_id the name of the model id
  • token go here to create a new πŸ€— token
  • checkpoint_dir checkpoint folder that will be uploaded
upload_ig_model(model_id='tony__assi-ig-prediction200',
             token='YOUR_HF_TOKEN',
             checkpoint_dir='./results/checkpoint-940')

Inference (Prediction)

  • repo_id πŸ€— repo id of the model
  • image_path path to image
predict_ig(repo_id='tonyassi/tony__assi-ig-prediction200',
        image_path='image.jpg')

The first time this function is called it'll download the safetensor model. Subsequent function calls will run faster.