Skip to content

Instantly share code, notes, and snippets.

View dsantiago's full-sized avatar

Diogo Santiago dsantiago

View GitHub Profile
def resize_image(image, input_size):
w, h = image.size
scale = input_size / max(w, h)
new_w = int(w * scale)
new_h = int(h * scale)
image = image.resize((new_w, new_h))
return image
@dsantiago
dsantiago / crop-function.py
Created June 1, 2024 15:27
Crop function in Google Cloud Function
from PIL import Image
import numpy as np
from io import BytesIO
from pathlib import Path
from google.cloud import storage
import functions_framework
SIZE = (768, 1024)
# Triggered by a change in a storage bucket

To use RoBERTa for classifying text into 32 types of documents, you can leverage the Hugging Face transformers library, which provides a pre-trained RoBERTa model that you can fine-tune for your specific classification task.

Here’s a step-by-step guide with code snippets on how to achieve this:

1. Install Necessary Libraries

First, you need to install the transformers and datasets libraries from Hugging Face, as well as torch for PyTorch.

pip install transformers datasets torch
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dsantiago
dsantiago / Autoencoder.ipynb
Last active September 3, 2023 20:23
Code for PEL309- CIência de Dados (Profa. Leila)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dsantiago
dsantiago / JsonParser.ipynb
Last active August 9, 2023 04:47
JsonParser.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.