Spaces:
Running
Running
File size: 872 Bytes
adc3639 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
from datasets import load_dataset
import random as r
dataset = load_dataset("TheFusion21/PokemonCards")
image_urls = dataset["train"]["image_url"]
image_des = dataset["train"]["caption"]
image_name = dataset["train"]["name"]
image_set_name = dataset["train"]["set_name"]
def choose_random_cards(n_cards: int = 5):
global image_urls, image_des, image_name, image_set_name
indexes = []
n = 0
while n < n_cards:
l = r.randint(0,len(image_urls))
if l not in indexes:
n+=1
indexes.append(l)
else:
continue
basestr = ""
c = 0
for idx in indexes:
c+=1
llmstr = f"CARD {c}:\n\nNAME:\n{image_name[idx]}\n\SET_NAME:\n{image_set_name[idx]}\n\nDESCRIPTION:\n{image_des[idx]}"
basestr+=llmstr+"\n\n\n"
urls = [image_urls[i] for i in indexes]
return basestr, urls
|