{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<bound method NDFrame.head of       Id         Character       Game\n",
       "0      1         Brimstone   Valorant\n",
       "1      2             Viper   Valorant\n",
       "2      3              Omen   Valorant\n",
       "3      4           Killjoy   Valorant\n",
       "4      5            Cypher   Valorant\n",
       "..   ...               ...        ...\n",
       "641  646         Kerillian  vermitide\n",
       "642  647  Victor Saltzpyre  vermitide\n",
       "643  648     Markus Kruber  vermitide\n",
       "644  649      Franz Lohner  vermitide\n",
       "645  650  Bardin Goreksson  vermitide\n",
       "\n",
       "[646 rows x 3 columns]>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dtst = pd.read_csv('character_names.csv')\n",
    "dtst.head"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "13\n"
     ]
    }
   ],
   "source": [
    "print(dtst['Game'].nunique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import csv\n",
    "import shutil\n",
    "\n",
    "# Path to the CSV file\n",
    "csv_file_path = 'character_names.csv'\n",
    "\n",
    "# Path to the character images directory\n",
    "images_dir_path = 'characterimages'\n",
    "\n",
    "# Path to the directory where you want to save the renamed images\n",
    "output_dir_path = 'images_by_character_renamed'\n",
    "\n",
    "# Create the output directory if it does not exist\n",
    "if not os.path.exists(output_dir_path):\n",
    "    os.makedirs(output_dir_path)\n",
    "\n",
    "# Read the CSV file and store the data in a dictionary\n",
    "character_game_mapping = {}\n",
    "with open(csv_file_path, mode='r', encoding='utf-8') as csv_file:\n",
    "    csv_reader = csv.DictReader(csv_file)\n",
    "    for row in csv_reader:\n",
    "        character_game_mapping[row['Character'].replace(' ', '_')] = row['Game']\n",
    "\n",
    "# Function to rename and move the images\n",
    "def process_images(character, game):\n",
    "    character_folder_path = os.path.join(images_dir_path, character)\n",
    "    if os.path.exists(character_folder_path):\n",
    "        for i in range(50):\n",
    "            old_image_name = f'image_{i:03}.jpg'\n",
    "            old_image_path = os.path.join(character_folder_path, old_image_name)\n",
    "            if os.path.exists(old_image_path):\n",
    "                new_image_name = f'{game}_{character}_{i}.jpg'\n",
    "                outdir = '/' + game + '/' + character + '/'\n",
    "                if not os.path.exists(output_dir_path+outdir):\n",
    "                    os.makedirs(output_dir_path+outdir)\n",
    "                new_image_path = os.path.join(output_dir_path + outdir, new_image_name)\n",
    "                shutil.move(old_image_path, new_image_path)\n",
    "\n",
    "# Iterate over the character-game mapping and process each character\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "for character, game in character_game_mapping.items():\n",
    "    process_images(character, game)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3d, audience, bicycle, blur censor, blurry, blurry background, blurry foreground, bokeh, building, cafe, camera, caution tape, cellphone picture, chain-link fence, chromatic aberration, city, concert, cosplay photo, crowd, debris, depth of field, electric fan, ferris wheel, figure, film grain, focused, glowstick, graffiti, hammock, motion blur, outdoors, park, people, perspective, photo \\(medium\\), photo background, photo inset, photorealistic, pool, poster \\(object\\), pov, pov hands, rainbow, reference inset, shadow, shopping, stadium, storefront, street, taking picture, town, unconventional media, viewfinder, volleyball\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "f = open('character-labeling.json')\n",
    "loaded_labels =json.load(f)\n",
    "print(loaded_labels['Apex Legends_Ash_0.jpg'])\n",
    "# labeling = json.decoder.JSONDecoder.decode(loaded_labels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Valorant_Brimstone\n",
      "Dota 2_Viper\n",
      "Valorant_Omen\n",
      "Valorant_Killjoy\n",
      "Valorant_Cypher\n",
      "Valorant_Sova\n",
      "Valorant_Sage\n",
      "Dota 2_Phoenix\n",
      "Valorant_Jett\n",
      "Battleborn_Reyna\n",
      "Valorant_Raze\n",
      "Valorant_Breach\n",
      "Valorant_Skye\n",
      "Valorant_Yoru\n",
      "Valorant_Astra\n",
      "Valorant_KAYO\n",
      "Valorant_Chamber\n",
      "Valorant_Neon\n",
      "Valorant_Fade\n",
      "Valorant_Harbor\n",
      "Valorant_Gekko\n",
      "Valorant_Deadlock\n",
      "Valorant_Iso\n",
      "League Of Legends_AATROX\n",
      "League Of Legends_AHRI\n",
      "League Of Legends_AKALI\n",
      "League Of Legends_AKSHAN\n",
      "League Of Legends_ALISTAR\n",
      "League Of Legends_AMUMU\n",
      "League Of Legends_ANIVIA\n",
      "League Of Legends_ANNIE\n",
      "League Of Legends_APHELIOS\n",
      "Overwatch_ASHE\n",
      "League Of Legends_AURELION_SOL\n",
      "League Of Legends_AZIR\n",
      "League Of Legends_BARD\n",
      "League Of Legends_BEL'VETH\n",
      "League Of Legends_BLITZCRANK\n",
      "League Of Legends_BRAND\n",
      "League Of Legends_BRAUM\n",
      "League Of Legends_BRIAR\n",
      "League Of Legends_CAITLYN\n",
      "League Of Legends_CAMILLE\n",
      "League Of Legends_CASSIOPEIA\n",
      "League Of Legends_CHO'GATH\n",
      "League Of Legends_CORKI\n",
      "League Of Legends_DARIUS\n",
      "League Of Legends_DIANA\n",
      "League Of Legends_DR._MUNDO\n",
      "League Of Legends_DRAVEN\n",
      "League Of Legends_EKKO\n",
      "League Of Legends_ELISE\n",
      "League Of Legends_EVELYNN\n",
      "League Of Legends_EZREAL\n",
      "League Of Legends_FIDDLESTICKS\n",
      "League Of Legends_FIORA\n",
      "League Of Legends_FIZZ\n",
      "League Of Legends_GALIO\n",
      "League Of Legends_GANGPLANK\n",
      "League Of Legends_GAREN\n",
      "League Of Legends_GNAR\n",
      "League Of Legends_GRAGAS\n",
      "League Of Legends_GRAVES\n",
      "League Of Legends_GWEN\n",
      "League Of Legends_HECARIM\n",
      "League Of Legends_HEIMERDINGER\n",
      "League Of Legends_ILLAOI\n",
      "League Of Legends_IRELIA\n",
      "League Of Legends_IVERN\n",
      "League Of Legends_JANNA\n",
      "League Of Legends_JARVAN_IV\n",
      "League Of Legends_JAX\n",
      "League Of Legends_JAYCE\n",
      "League Of Legends_JHIN\n",
      "League Of Legends_JINX\n",
      "League Of Legends_K'SANTE\n",
      "League Of Legends_KAI'SA\n",
      "League Of Legends_KALISTA\n",
      "League Of Legends_KARMA\n",
      "League Of Legends_KARTHUS\n",
      "League Of Legends_KASSADIN\n",
      "League Of Legends_KATARINA\n",
      "League Of Legends_KAYLE\n",
      "League Of Legends_KAYN\n",
      "League Of Legends_KENNEN\n",
      "League Of Legends_KHA'ZIX\n",
      "League Of Legends_KINDRED\n",
      "League Of Legends_KLED\n",
      "League Of Legends_KOG'MAW\n",
      "League Of Legends_LEBLANC\n",
      "League Of Legends_LEE_SIN\n",
      "League Of Legends_LEONA\n",
      "League Of Legends_LILLIA\n",
      "League Of Legends_LISSANDRA\n",
      "League Of Legends_LUCIAN\n",
      "League Of Legends_LULU\n",
      "League Of Legends_LUX\n",
      "League Of Legends_MALPHITE\n",
      "League Of Legends_MALZAHAR\n",
      "League Of Legends_MAOKAI\n",
      "League Of Legends_MASTER_YI\n",
      "League Of Legends_MILIO\n",
      "League Of Legends_MISS_FORTUNE\n",
      "League Of Legends_MORDEKAISER\n",
      "League Of Legends_MORGANA\n",
      "League Of Legends_NAAFIRI\n",
      "League Of Legends_NAMI\n",
      "League Of Legends_NASUS\n",
      "League Of Legends_NAUTILUS\n",
      "League Of Legends_NEEKO\n",
      "League Of Legends_NIDALEE\n",
      "League Of Legends_NILAH\n",
      "League Of Legends_NOCTURNE\n",
      "League Of Legends_NUNU_&_WILLUMP\n",
      "League Of Legends_OLAF\n",
      "League Of Legends_ORIANNA\n",
      "League Of Legends_ORNN\n",
      "League Of Legends_PANTHEON\n",
      "League Of Legends_POPPY\n",
      "League Of Legends_PYKE\n",
      "League Of Legends_QIYANA\n",
      "League Of Legends_QUINN\n",
      "League Of Legends_RAKAN\n",
      "League Of Legends_RAMMUS\n",
      "League Of Legends_REK'SAI\n",
      "League Of Legends_RELL\n",
      "League Of Legends_RENATA_GLASC\n",
      "League Of Legends_RENEKTON\n",
      "League Of Legends_RENGAR\n",
      "League Of Legends_RIVEN\n",
      "League Of Legends_RUMBLE\n",
      "League Of Legends_RYZE\n",
      "League Of Legends_SAMIRA\n",
      "League Of Legends_SEJUANI\n",
      "League Of Legends_SENNA\n",
      "League Of Legends_SERAPHINE\n",
      "League Of Legends_SETT\n",
      "League Of Legends_SHACO\n",
      "League Of Legends_SHEN\n",
      "League Of Legends_SHYVANA\n",
      "League Of Legends_SINGED\n",
      "League Of Legends_SION\n",
      "League Of Legends_SIVIR\n",
      "League Of Legends_SKARNER\n",
      "League Of Legends_SONA\n",
      "League Of Legends_SORAKA\n",
      "League Of Legends_SWAIN\n",
      "League Of Legends_SYLAS\n",
      "League Of Legends_SYNDRA\n",
      "League Of Legends_TAHM_KENCH\n",
      "League Of Legends_TALIYAH\n",
      "League Of Legends_TALON\n",
      "League Of Legends_TARIC\n",
      "League Of Legends_TEEMO\n",
      "League Of Legends_THRESH\n",
      "League Of Legends_TRISTANA\n",
      "League Of Legends_TRUNDLE\n",
      "League Of Legends_TRYNDAMERE\n",
      "League Of Legends_TWISTED_FATE\n",
      "Rainbow six seige_TWITCH\n",
      "League Of Legends_UDYR\n",
      "League Of Legends_URGOT\n",
      "League Of Legends_VARUS\n",
      "League Of Legends_VAYNE\n",
      "League Of Legends_VEIGAR\n",
      "League Of Legends_VEL'KOZ\n",
      "League Of Legends_VEX\n",
      "League Of Legends_VI\n",
      "League Of Legends_VIEGO\n",
      "League Of Legends_VIKTOR\n",
      "League Of Legends_VLADIMIR\n",
      "League Of Legends_VOLIBEAR\n",
      "League Of Legends_WARWICK\n",
      "League Of Legends_WUKONG\n",
      "League Of Legends_XAYAH\n",
      "League Of Legends_XERATH\n",
      "League Of Legends_XIN_ZHAO\n",
      "League Of Legends_YASUO\n",
      "League Of Legends_YONE\n",
      "League Of Legends_YORICK\n",
      "League Of Legends_YUUMI\n",
      "League Of Legends_ZAC\n",
      "League Of Legends_ZED\n",
      "League Of Legends_ZERI\n",
      "League Of Legends_ZIGGS\n",
      "League Of Legends_ZILEAN\n",
      "League Of Legends_ZOE\n",
      "League Of Legends_ZYRA\n",
      "Overwatch_ANA\n",
      "Overwatch_BAPTISTE\n",
      "Overwatch_BASTION\n",
      "Overwatch_BRIGITTE\n",
      "Overwatch_CASSIDY\n",
      "Overwatch_D.VA\n",
      "Overwatch_DOOMFIST\n",
      "Rainbow six seige_ECHO\n",
      "Overwatch_GENJI\n",
      "Overwatch_HANZO\n",
      "Overwatch_ILLARI\n",
      "Overwatch_JUNKER_QUEEN\n",
      "Overwatch_JUNKRAT\n",
      "Overwatch_KIRIKO\n",
      "Overwatch_LIFEWEAVER\n",
      "Overwatch_LÚCIO\n",
      "Overwatch_MEI\n",
      "Overwatch_MERCY\n",
      "Overwatch_MOIRA\n",
      "Overwatch_ORISA\n",
      "Overwatch_PHARAH\n",
      "Overwatch_RAMATTRA\n",
      "Overwatch_REAPER\n",
      "Overwatch_REINHARDT\n",
      "Overwatch_ROADHOG\n",
      "Overwatch_SIGMA\n",
      "Overwatch_SOJOURN\n",
      "Overwatch_SOLDIER_76\n",
      "Overwatch_SOMBRA\n",
      "Overwatch_SYMMETRA\n",
      "Overwatch_TORBJÖRN\n",
      "Overwatch_TRACER\n",
      "Overwatch_WIDOWMAKER\n",
      "Overwatch_WINSTON\n",
      "Overwatch_WRECKING_BALL\n",
      "Overwatch_ZARYA\n",
      "Overwatch_ZENYATTA\n",
      "Dota 2_Abaddon\n",
      "Dota 2_Alchemist\n",
      "Dota 2_Ancient_Apparition\n",
      "Dota 2_AntiMage\n",
      "Dota 2_Arc_Warden\n",
      "Dota 2_Axe\n",
      "Dota 2_Bane\n",
      "Dota 2_Batrider\n",
      "Dota 2_Beastmaster\n",
      "Dota 2_Bloodseeker\n",
      "Dota 2_Bounty_Hunter\n",
      "Dota 2_Brewmaster\n",
      "Dota 2_Bristleback\n",
      "Dota 2_Broodmother\n",
      "Dota 2_Centaur_Warrunner\n",
      "Dota 2_Chaos_Knight\n",
      "Dota 2_Chen\n",
      "Dota 2_Clinkz\n",
      "Dota 2_Clockwerk\n",
      "Dota 2_Crystal_Maiden\n",
      "Dota 2_Dark_Seer\n",
      "Dota 2_Dark_Willow\n",
      "Dota 2_Dawnbreaker\n",
      "Dota 2_Dazzle\n",
      "Dota 2_Death_Prophet\n",
      "Dota 2_Disruptor\n",
      "Dota 2_Doom\n",
      "Dota 2_Dragon_Knight\n",
      "Dota 2_Drow_Ranger\n",
      "Dota 2_Earth_Spirit\n",
      "Dota 2_Earthshaker\n",
      "Dota 2_Elder_Titan\n",
      "Dota 2_Ember_Spirit\n",
      "Dota 2_Enchantress\n",
      "Dota 2_Enigma\n",
      "Dota 2_Faceless_Void\n",
      "Dota 2_Grimstroke\n",
      "Dota 2_Gyrocopter\n",
      "Dota 2_Hoodwink\n",
      "Dota 2_Huskar\n",
      "Dota 2_Invoker\n",
      "Dota 2_Io\n",
      "Dota 2_Jakiro\n",
      "Dota 2_Juggernaut\n",
      "Dota 2_Keeper_of_the_Light\n",
      "Dota 2_Kunkka\n",
      "Dota 2_Legion_Commander\n",
      "Dota 2_Leshrac\n",
      "Dota 2_Lich\n",
      "Dota 2_Lifestealer\n",
      "Dota 2_Lina\n",
      "Dota 2_Lion\n",
      "Dota 2_Lone_Druid\n",
      "Dota 2_Luna\n",
      "Dota 2_Lycan\n",
      "Dota 2_Magnus\n",
      "Dota 2_Marci\n",
      "Dota 2_Mars\n",
      "Dota 2_Medusa\n",
      "Dota 2_Meepo\n",
      "Dota 2_Mirana\n",
      "Dota 2_Monkey_King\n",
      "Dota 2_Morphling\n",
      "Dota 2_Muerta\n",
      "Dota 2_Naga_Siren\n",
      "Dota 2_Natures_Prophet\n",
      "Dota 2_Necrophos\n",
      "Dota 2_Night_Stalker\n",
      "Dota 2_Nyx_Assassin\n",
      "Dota 2_Ogre_Magi\n",
      "Dota 2_Omniknight\n",
      "Dota 2_Oracle\n",
      "Dota 2_Outworld_Destroyer\n",
      "Dota 2_Pangolier\n",
      "Dota 2_Phantom_Assassin\n",
      "Dota 2_Phantom_Lancer\n",
      "Dota 2_Primal_Beast\n",
      "Dota 2_Puck\n",
      "Dota 2_Pudge\n",
      "Dota 2_Pugna\n",
      "Dota 2_Queen_of_Pain\n",
      "Genshin Impact_Razor\n",
      "Dota 2_Riki\n",
      "Dota 2_Rubick\n",
      "Dota 2_Sand_King\n",
      "Dota 2_Shadow_Demon\n",
      "Dota 2_Shadow_Fiend\n",
      "Dota 2_Shadow_Shaman\n",
      "Dota 2_Silencer\n",
      "Dota 2_Skywrath_Mage\n",
      "Dota 2_Slardar\n",
      "Dota 2_Slark\n",
      "Dota 2_Snapfire\n",
      "Dota 2_Sniper\n",
      "Dota 2_Spectre\n",
      "Dota 2_Spirit_Breaker\n",
      "Dota 2_Storm_Spirit\n",
      "Dota 2_Sven\n",
      "Dota 2_Techies\n",
      "Dota 2_Templar_Assassin\n",
      "Dota 2_Terrorblade\n",
      "Dota 2_Tidehunter\n",
      "Dota 2_Timbersaw\n",
      "Dota 2_Tinker\n",
      "Dota 2_Tiny\n",
      "Dota 2_Treant_Protector\n",
      "Dota 2_Troll_Warlord\n",
      "Dota 2_Tusk\n",
      "Dota 2_Underlord\n",
      "Dota 2_Undying\n",
      "Dota 2_Ursa\n",
      "Dota 2_Vengeful_Spirit\n",
      "Dota 2_Venomancer\n",
      "Dota 2_Visage\n",
      "Dota 2_Void_Spirit\n",
      "Dota 2_Warlock\n",
      "Dota 2_Weaver\n",
      "Dota 2_Windranger\n",
      "Dota 2_Winter_Wyvern\n",
      "Dota 2_Witch_Doctor\n",
      "Dota 2_Wraith_King\n",
      "Dota 2_Zeus\n",
      "Apex Legends_Ash\n",
      "Apex Legends_Bangalore\n",
      "Apex Legends_Fuse\n",
      "Apex Legends_Horizon\n",
      "Apex Legends_Mirage\n",
      "Apex Legends_Octane\n",
      "Apex Legends_Revenant\n",
      "Apex Legends_Wraith\n",
      "Apex Legends_Mad_Maggie\n",
      "Apex Legends_Caustic\n",
      "Apex Legends_Gibraltar\n",
      "Apex Legends_Rampart\n",
      "Apex Legends_Wattson\n",
      "Apex Legends_Catalyst\n",
      "Apex Legends_Lifeline\n",
      "Apex Legends_Loba\n",
      "Apex Legends_Newcastle\n",
      "Apex Legends_Bloodhound\n",
      "Apex Legends_Crypto\n",
      "Apex Legends_Pathfinder\n",
      "Apex Legends_Seer\n",
      "Apex Legends_Valkyrie\n",
      "Apex Legends_Vantage\n",
      "Rainbow six seige_RAM\n",
      "Rainbow six seige_FENRIR\n",
      "Rainbow six seige_BRAVA\n",
      "Rainbow six seige_SOLIS\n",
      "Rainbow six seige_GRIM\n",
      "Rainbow six seige_SENS\n",
      "Rainbow six seige_AZAMI\n",
      "Rainbow six seige_THORN\n",
      "Rainbow six seige_OSA\n",
      "Rainbow six seige_THUNDERBIRD\n",
      "Rainbow six seige_FLORES\n",
      "Rainbow six seige_ARUNI\n",
      "Rainbow six seige_ZERO\n",
      "Rainbow six seige_ACE\n",
      "Rainbow six seige_MELUSI\n",
      "Rainbow six seige_ORYX\n",
      "Rainbow six seige_IANA\n",
      "Rainbow six seige_WAMAI\n",
      "Rainbow six seige_KALI\n",
      "Rainbow six seige_AMARU\n",
      "Rainbow six seige_GOYO\n",
      "Rainbow six seige_NOKK\n",
      "Rainbow six seige_WARDEN\n",
      "Rainbow six seige_MOZZIE\n",
      "Rainbow six seige_GRIDLOCK\n",
      "Rainbow six seige_NOMAD\n",
      "Rainbow six seige_KAID\n",
      "Rainbow six seige_CLASH\n",
      "Rainbow six seige_MAVERICK\n",
      "Rainbow six seige_MAESTRO\n",
      "Rainbow six seige_ALIBI\n",
      "Rainbow six seige_LION\n",
      "Rainbow six seige_FINKA\n",
      "Rainbow six seige_VIGIL\n",
      "Rainbow six seige_DOKKAEBI\n",
      "Rainbow six seige_ZOFIA\n",
      "Rainbow six seige_ELA\n",
      "Rainbow six seige_YING\n",
      "Rainbow six seige_LESION\n",
      "Rainbow six seige_MIRA\n",
      "Rainbow six seige_JACKAL\n",
      "Rainbow six seige_HIBANA\n",
      "Rainbow six seige_CAVEIRA\n",
      "Rainbow six seige_CAPITÃO\n",
      "Rainbow six seige_BLACKBEARD\n",
      "Rainbow six seige_VALKYRIE\n",
      "Rainbow six seige_BUCK\n",
      "Rainbow six seige_FROST\n",
      "Rainbow six seige_MUTE\n",
      "Rainbow six seige_SLEDGE\n",
      "Rainbow six seige_SMOKE\n",
      "Rainbow six seige_THATCHER\n",
      "Rainbow six seige_ASH\n",
      "Rainbow six seige_CASTLE\n",
      "Rainbow six seige_PULSE\n",
      "Rainbow six seige_THERMITE\n",
      "Rainbow six seige_MONTAGNE\n",
      "Rainbow six seige_DOC\n",
      "Rainbow six seige_ROOK\n",
      "Rainbow six seige_JÄGER\n",
      "Rainbow six seige_BANDIT\n",
      "Rainbow six seige_BLITZ\n",
      "Rainbow six seige_IQ\n",
      "Rainbow six seige_FUZE\n",
      "Rainbow six seige_GLAZ\n",
      "Rainbow six seige_TACHANKA\n",
      "Rainbow six seige_KAPKAN\n",
      "Genshin Impact_Albedo\n",
      "Genshin Impact_Alhaitham\n",
      "Genshin Impact_Aloy\n",
      "Genshin Impact_Amber\n",
      "Genshin Impact_Arataki_Itto\n",
      "Genshin Impact_Barbara\n",
      "Genshin Impact_Beidou\n",
      "Genshin Impact_Bennett\n",
      "Genshin Impact_Candace\n",
      "Genshin Impact_Chongyun\n",
      "Genshin Impact_Collei\n",
      "Genshin Impact_Cyno\n",
      "Genshin Impact_Diluc\n",
      "Genshin Impact_Diona\n",
      "Genshin Impact_Dori\n",
      "Genshin Impact_Eula\n",
      "Genshin Impact_Faruzan\n",
      "Genshin Impact_Fischl\n",
      "Genshin Impact_Ganyu\n",
      "Genshin Impact_Gorou\n",
      "Genshin Impact_Hu_Tao\n",
      "Genshin Impact_Jean\n",
      "Genshin Impact_Kaedehara_Kazuha\n",
      "Genshin Impact_Kaeya\n",
      "Genshin Impact_Kamisato_Ayaka\n",
      "Genshin Impact_Kamisato_Ayato\n",
      "Genshin Impact_Keqing\n",
      "Genshin Impact_Klee\n",
      "Genshin Impact_Kujou_Sara\n",
      "Genshin Impact_Kuki_Shinobu\n",
      "Genshin Impact_Layla\n",
      "Genshin Impact_Lisa\n",
      "Genshin Impact_Mona\n",
      "Genshin Impact_Nahida\n",
      "Genshin Impact_Nilou\n",
      "Genshin Impact_Ningguang\n",
      "Genshin Impact_Noelle\n",
      "Genshin Impact_Qiqi\n",
      "Genshin Impact_Raiden_Shogun\n",
      "Genshin Impact_Rosaria\n",
      "Genshin Impact_Sangonomiya_Kokomi\n",
      "Genshin Impact_Sayu\n",
      "Genshin Impact_Shenhe\n",
      "Genshin Impact_Shikanoin_Heizou\n",
      "Genshin Impact_Sucrose\n",
      "Genshin Impact_TartagliaChilde\n",
      "Genshin Impact_Thoma\n",
      "Genshin Impact_Tighnari\n",
      "Genshin Impact_Venti\n",
      "Genshin Impact_Wanderer\n",
      "Genshin Impact_Xiangling\n",
      "Genshin Impact_Xiao\n",
      "Genshin Impact_Xingqiu\n",
      "Genshin Impact_Xinyan\n",
      "Genshin Impact_Yae_Miko\n",
      "Genshin Impact_Yanfei\n",
      "Genshin Impact_Yaoyao\n",
      "Genshin Impact_Yelan\n",
      "Genshin Impact_Yoimiya\n",
      "Genshin Impact_Yun_Jin\n",
      "Genshin Impact_Zhongli\n",
      "Halo_Master_Chief\n",
      "Halo_Cortana\n",
      "Halo_Avery_Johnson\n",
      "Halo_Jacob_Keyes\n",
      "Halo_Miranda_Keyes\n",
      "Halo_Dr.Catherine_Halsey\n",
      "Halo_James_Ackerson\n",
      "Halo_Franklin_Mendez\n",
      "Halo_Terrence_Hood\n",
      "Halo_Serin_Osman\n",
      "Halo_Thomas_Lasky\n",
      "Halo_Roland\n",
      "Halo_The_Weapon\n",
      "Halo_Echo216\n",
      "Halo_Fred104\n",
      "Halo_Linda058\n",
      "Halo_Kelly087\n",
      "Halo_Sarah_Palmer\n",
      "Halo_Edward_Buck\n",
      "Halo_Noble_Six\n",
      "Halo_Jameson_Locke\n",
      "Halo_Mickey_Crespo\n",
      "Halo_Romeo_Agusto\n",
      "Halo_Dutch_Miles\n",
      "Halo_The_Arbiter\n",
      "Halo_Tartarus\n",
      "Halo_Gravemind\n",
      "Halo_343_Guilty_Spark\n",
      "Halo_Rtas_Vadum\n",
      "Halo_Thel_Vadam\n",
      "Halo_Vor_Donnie_Atin\n",
      "Quake Champions_Anarki\n",
      "Quake Champions_Doomguy\n",
      "Quake Champions_Bj_blazkowicz\n",
      "Quake Champions_Sorlag\n",
      "Quake Champions_Galena\n",
      "Quake Champions_Scalebearer\n",
      "Quake Champions_Athena\n",
      "Quake Champions_Bitterman\n",
      "Quake Champions_Sarge\n",
      "Quake Champions_H_u_n_t_e_r\n",
      "Quake Champions_Strogg__peeker\n",
      "Quake Champions_Quake_Guy\n",
      "Quake Champions_Mynx\n",
      "Quake Champions_Dire_Orb\n",
      "Quake Champions_Chthon\n",
      "Quake Champions_Strogg\n",
      "Quake Champions_Xaero\n",
      "Quake Champions_Tank_jr\n",
      "Quake Champions_Phobos\n",
      "Quake Champions_Duke_Nukem\n",
      "Quake Champions_Makron\n",
      "Quake Champions_Kane\n",
      "Quake Champions_Caleb\n",
      "Quake Champions_Eleena\n",
      "Hades_Dusa\n",
      "Hades_Asterius\n",
      "Hades_Megaera\n",
      "Hades_Thanatos\n",
      "Hades_Artemis\n",
      "Hades_Alecto\n",
      "Hades_Dionysus\n",
      "Hades_Hypnos\n",
      "Hades_Zagreus\n",
      "Hades_Aphrodite\n",
      "Hades_Pain_and_Panic\n",
      "Hades_Hercules\n",
      "Hades_Megara\n",
      "Hades_Fates\n",
      "Hades_Melinoë\n",
      "Call Of Duty_Price\n",
      "Call Of Duty_John_McClane\n",
      "Call Of Duty_Khaled_AlAsad\n",
      "Call Of Duty_Russell_Adler\n",
      "Call Of Duty_Arthur_Kingsley\n",
      "Call Of Duty_Simon_Ghost_Riley\n",
      "Call Of Duty_Ghostface\n",
      "Call Of Duty_David_Mason\n",
      "Call Of Duty_Frank_Woods\n",
      "Call Of Duty_John_Rambo\n",
      "Call Of Duty_Dimitri_Petrenko\n",
      "Call Of Duty_Norman_Delaney\n",
      "Call Of Duty_Sarah_Leary\n",
      "Call Of Duty_Grigori_Weaver\n",
      "Call Of Duty_Blake\n",
      "Call Of Duty_Booth\n",
      "Call Of Duty_Vladimir_Makarov\n",
      "Call Of Duty_Wade_Jackson\n",
      "Call Of Duty_Alex_Mason\n",
      "Call Of Duty_Nikolai_Belinski\n",
      "Call Of Duty_Neitsch\n",
      "Call Of Duty_Bohater_Wojciech\n",
      "Call Of Duty_Helen_Park\n",
      "Call Of Duty_Black_Noir\n",
      "Call Of Duty_Paul_Jackson\n",
      "Call Of Duty_John_Davis\n",
      "Call Of Duty_Brock\n",
      "Call Of Duty_Sergei_Konstantinov\n",
      "Call Of Duty_Jason_Hudson\n",
      "Call Of Duty_Farid\n",
      "Call Of Duty_T1000\n",
      "Call Of Duty_21_Savage\n",
      "Call Of Duty_Billy_Handsome\n",
      "Call Of Duty_Nikolai_Badanov\n",
      "Call Of Duty_Gary\n",
      "Call Of Duty_Logan_Walker\n",
      "Call Of Duty_Joseph_Allen\n",
      "Call Of Duty_Robert_McNamara\n",
      "Call Of Duty_Lucas_Riggs\n",
      "Call Of Duty_Edward_Carlyle\n",
      "Call Of Duty_Viktor_Reznov\n",
      "Call Of Duty_Fidel_Castro\n",
      "Call Of Duty_George_Barkley\n",
      "Call Of Duty_Marcus_Burns\n",
      "Call Of Duty_Yasir_AlFulani\n",
      "Call Of Duty_Abigail_Misty_Briarton\n",
      "Call Of Duty_Sergei_Kozin\n",
      "Call Of Duty_Castros_Double\n",
      "Call Of Duty_Gaines\n",
      "Battleborn_Miko\n",
      "Battleborn_Orendi\n",
      "Battleborn_El_Dragón\n",
      "Battleborn_Galilea\n",
      "Battleborn_Kleese\n",
      "Battleborn_R_a_t_h\n",
      "Battleborn_Battleborn\n",
      "Battleborn_Beatrix\n",
      "Battleborn_Benedict\n",
      "Battleborn_Kelvin\n",
      "Battleborn_Montana\n",
      "Battleborn_Oscar_Mike\n",
      "Battleborn_Phoebe\n",
      "Battleborn_Shayne_and_Aurox\n",
      "Battleborn_Toby\n",
      "Battleborn_Whiskey_foxtrot\n",
      "Battleborn_Marquis\n",
      "vermitide_Kerillian\n",
      "vermitide_Victor_Saltzpyre\n",
      "vermitide_Markus_Kruber\n",
      "vermitide_Franz_Lohner\n",
      "vermitide_Bardin_Goreksson\n"
     ]
    }
   ],
   "source": [
    "output_path = 'labels_by_image'\n",
    "for image in character_game_mapping.items():\n",
    "    image_name = image[1] + '_' + image[0]\n",
    "    print(image_name)\n",
    "    game_path = output_path + '/' + image[1]\n",
    "    character_path = game_path + '/' + image[0]\n",
    "    character_labels = {}\n",
    "    if not os.path.exists(character_path):\n",
    "        os.makedirs(character_path)\n",
    "    for i in range(50):\n",
    "        name = image_name + '_' + str(i)\n",
    "        full_name = name + '.jpg'\n",
    "        full_path = character_path + '/' + name + '.txt'\n",
    "        if full_name in loaded_labels:\n",
    "            f = open(full_path, \"w\")\n",
    "            f.write(loaded_labels[full_name])\n",
    "            f.close()\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "\n",
    "def add_keyword_to_text_files(directory, keyword):\n",
    "    for filename in os.listdir(directory):\n",
    "        if filename.endswith('.txt'):  # Check if the file is a text file\n",
    "            file_path = os.path.join(directory, filename)\n",
    "            with open(file_path, 'r+', encoding='utf-8') as file:\n",
    "                content = file.read()\n",
    "                if keyword not in content:\n",
    "                    file.write(', ' + keyword)  # Append the keyword at the end of the file\n",
    "\n",
    "# Replace with your directory path and the keyword you want to add\n",
    "directory_path = 'labels_by_image/Genshin Impact/Raiden_Shogun'\n",
    "keyword = 'genshin impact'\n",
    "\n",
    "add_keyword_to_text_files(directory_path, keyword)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "MachineLearning",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
