Instructions to use hugaagg/IR_expeiment with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use hugaagg/IR_expeiment with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("hugaagg/IR_expeiment", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
| import os | |
| import random | |
| def create_path(IMGS_PATH, list_new_files): | |
| ''' | |
| Util function to add the file path of all the images to the list of names of the selected | |
| images that will form the valid ones. | |
| ''' | |
| file_path, name = os.path.split( | |
| IMGS_PATH[0]) # we pick only one element of the list | |
| output = [os.path.join(file_path, element) for element in list_new_files] | |
| return output | |
| def common_member(a, b): | |
| ''' | |
| Returns true if the two lists (valid and training) have a common element. | |
| ''' | |
| a_set = set(a) | |
| b_set = set(b) | |
| if (a_set & b_set): | |
| return True | |
| else: | |
| return False | |
| def random_sort_pairs(list1, list2): | |
| ''' | |
| This function makes the same random sort to each list, so that they are sorted and the pairs are maintained. | |
| ''' | |
| # Combine the lists | |
| combined = list(zip(list1, list2)) | |
| # Shuffle the combined list | |
| random.shuffle(combined) | |
| # Unzip back into separate lists | |
| list1[:], list2[:] = zip(*combined) | |
| return list1, list2 | |
| def flatten_list_comprehension(matrix): | |
| return [item for row in matrix for item in row] | |
| def check_paths(list_of_lists): | |
| ''' | |
| check if all the image routes are correct | |
| ''' | |
| paths = flatten_list_comprehension(list_of_lists) | |
| trues = [os.path.isfile(file) for file in paths] | |
| counter = 0 | |
| for true, path in zip(trues, paths): | |
| if true != True: | |
| print('Non valid route!', path) | |
| counter +=1 |