diff --git a/README.md b/README.md index f8f194640c7743a716414ec0cf07ea19dcafa95a..8a72ec11d5d5b77da275005ead9c36547e26162f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,6 @@ --- -title: Random Word Genrator -emoji: 📊 -colorFrom: purple -colorTo: blue -sdk: gradio -sdk_version: 4.22.0 +title: Random_Word_Genrator app_file: app.py -pinned: false +sdk: gradio +sdk_version: 4.19.1 --- - -Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference diff --git a/app.py b/app.py new file mode 100644 index 0000000000000000000000000000000000000000..a4cc1b9b90fbadbbbd1e3b310b3db820c76f9e81 --- /dev/null +++ b/app.py @@ -0,0 +1,92 @@ +import os +import random +import cv2 +import gradio as gr +from PIL import Image +import numpy as np + +def generate_and_delete_word_image(word): + """Generates a combined image, displays it, and deletes it afterward. + + Args: + word: The user-provided word (uppercase). + + Returns: + The image data for displaying. + """ + + dataset_path = "C:\DYPIU\___________________CODE___________________\Random Word Genrator\dataset" # Adjust for your dataset path + sample = "C:\DYPIU\___________________CODE___________________\Random Word Genrator\dataset\samples.jpg" + resized_images = [] + for letter in word: + letter_folder_path = os.path.join(dataset_path, letter) + + # Check if the folder exists + if not os.path.isdir(letter_folder_path): + print("Folder not found for the letter:", letter) + continue + + images_in_folder = [img for img in os.listdir(letter_folder_path) + if img.endswith(".jpg") or img.endswith(".png")] + + if not images_in_folder: + print("No images found for the letter:", letter) + continue + + # Randomly select an image from the folder + random_image_name = random.choice(images_in_folder) + image_path = os.path.join(letter_folder_path, random_image_name) + + try: + # Load image using PIL, ensuring RGB mode + image = Image.open(image_path).convert("RGB") + # Convert to NumPy array for OpenCV + resized_image = np.array(image.resize((250, 250))) + except Exception as e: + print(f"Error loading image: {e}") + continue + + resized_images.append(resized_image) + + if not resized_images: + print("No images found for the input word.") + return None + + sample_img = sample + concatenated_image = cv2.hconcat(resized_images) + + # Display the concatenated image + # cv2.imshow("Concatenated Image", concatenated_image) + # cv2.waitKey(0) + # cv2.destroyAllWindows() + + # Return the image data + return concatenated_image + +# Gradio interface with clear explanations +interface = gr.Interface( + fn=generate_and_delete_word_image, + inputs="text", # User input for the word + outputs="image", # Output as an image + title="POCKET RANDOM NOTE GENERATOR", # Title + description="Randsomator allows you to generate random ranson with one click.", + + css=""" + botton { + background: green; + color: #32B531 + } + body { + background-color: black; + font-family: Arial, sans-serif; + } + .gr-interactive-component h1 { + font-size: 20px; + margin-bottom: 10px; + } + """, + +) + + +interface.launch(share=True) # Launch the Gradio interface and share it publicly diff --git a/dataset/0/0.png b/dataset/0/0.png new file mode 100644 index 0000000000000000000000000000000000000000..195ee051943ea6ab90a92627e30e8b564e1596a9 Binary files /dev/null and b/dataset/0/0.png differ diff --git a/dataset/0/02.png b/dataset/0/02.png new file mode 100644 index 0000000000000000000000000000000000000000..a0e648492d3ef073d6507c728864b9f8cdb0dcde Binary files /dev/null and b/dataset/0/02.png differ diff --git a/dataset/1/1.png b/dataset/1/1.png new file mode 100644 index 0000000000000000000000000000000000000000..fca96de3834afe4f84134602c9eec4faa4a359b3 Binary files /dev/null and b/dataset/1/1.png differ diff --git a/dataset/1/12.png b/dataset/1/12.png new file mode 100644 index 0000000000000000000000000000000000000000..214d72c9d73bc10d00ba23b04c8c576a1b5a8901 Binary files /dev/null and b/dataset/1/12.png differ diff --git a/dataset/2/21.png b/dataset/2/21.png new file mode 100644 index 0000000000000000000000000000000000000000..bfa685b37d16ee0e1f252a7b0fe1f15e641119f9 Binary files /dev/null and b/dataset/2/21.png differ diff --git a/dataset/2/22.png b/dataset/2/22.png new file mode 100644 index 0000000000000000000000000000000000000000..4d4900342068fbfa9b0172e92ea78146aa040063 Binary files /dev/null and b/dataset/2/22.png differ diff --git a/dataset/2/23.png b/dataset/2/23.png new file mode 100644 index 0000000000000000000000000000000000000000..fdacc83b69daa6784b742272f9921df37da66596 Binary files /dev/null and b/dataset/2/23.png differ diff --git a/dataset/2/24.png b/dataset/2/24.png new file mode 100644 index 0000000000000000000000000000000000000000..0d1c6372dfe87bd5dda81c09222765827ecb2bbf Binary files /dev/null and b/dataset/2/24.png differ diff --git a/dataset/3/3.png b/dataset/3/3.png new file mode 100644 index 0000000000000000000000000000000000000000..14ffaa5962790d1d1d26c8a6e72f7a515a7f1692 Binary files /dev/null and b/dataset/3/3.png differ diff --git a/dataset/3/32.png b/dataset/3/32.png new file mode 100644 index 0000000000000000000000000000000000000000..099f8c33e8a08cef5f954319ec1a7e8d41001907 Binary files /dev/null and b/dataset/3/32.png differ diff --git a/dataset/3/33.png b/dataset/3/33.png new file mode 100644 index 0000000000000000000000000000000000000000..a5b4a5a441134684665a957e83eb4a38e8fdd3f8 Binary files /dev/null and b/dataset/3/33.png differ diff --git a/dataset/4/4.png b/dataset/4/4.png new file mode 100644 index 0000000000000000000000000000000000000000..58dd9f468e9c26cea415055999f49c1acec6953e Binary files /dev/null and b/dataset/4/4.png differ diff --git a/dataset/4/42.png b/dataset/4/42.png new file mode 100644 index 0000000000000000000000000000000000000000..6b9d8e428eb6250c5ad9c62f0f8179a3e462a4ee Binary files /dev/null and b/dataset/4/42.png differ diff --git a/dataset/4/43.png b/dataset/4/43.png new file mode 100644 index 0000000000000000000000000000000000000000..a6447de2f61aec528d97aa6ae31435c17e921b20 Binary files /dev/null and b/dataset/4/43.png differ diff --git a/dataset/5/5.png b/dataset/5/5.png new file mode 100644 index 0000000000000000000000000000000000000000..0b2c7316f5c5bc27593eb35e52d51669a32fb3b4 Binary files /dev/null and b/dataset/5/5.png differ diff --git a/dataset/5/52.png b/dataset/5/52.png new file mode 100644 index 0000000000000000000000000000000000000000..5dbbbed6227d91ff32659133363777ea76dd6543 Binary files /dev/null and b/dataset/5/52.png differ diff --git a/dataset/5/53.png b/dataset/5/53.png new file mode 100644 index 0000000000000000000000000000000000000000..1d2757201f883d0250129c04bb900762ed8d4ffe Binary files /dev/null and b/dataset/5/53.png differ diff --git a/dataset/6/6.png b/dataset/6/6.png new file mode 100644 index 0000000000000000000000000000000000000000..24dc844f623ac96cbb552c102fb0c345db241ed3 Binary files /dev/null and b/dataset/6/6.png differ diff --git a/dataset/6/62.png b/dataset/6/62.png new file mode 100644 index 0000000000000000000000000000000000000000..c4af9ae08694582778a6c3183a8d2a2e138529ae Binary files /dev/null and b/dataset/6/62.png differ diff --git a/dataset/6/63.png b/dataset/6/63.png new file mode 100644 index 0000000000000000000000000000000000000000..a2925127115960df6350790c2c09bbca927541ca Binary files /dev/null and b/dataset/6/63.png differ diff --git a/dataset/6/64.png b/dataset/6/64.png new file mode 100644 index 0000000000000000000000000000000000000000..c688517263e2c5b57cc40eae2373d66245d6d677 Binary files /dev/null and b/dataset/6/64.png differ diff --git a/dataset/7/7.png b/dataset/7/7.png new file mode 100644 index 0000000000000000000000000000000000000000..de755d07c1cc448a2acd8e04a8ae8b64f33ba0d8 Binary files /dev/null and b/dataset/7/7.png differ diff --git a/dataset/7/71.png b/dataset/7/71.png new file mode 100644 index 0000000000000000000000000000000000000000..c6c65b73699bd65053417c413bed1e4e4436230f Binary files /dev/null and b/dataset/7/71.png differ diff --git a/dataset/7/72.png b/dataset/7/72.png new file mode 100644 index 0000000000000000000000000000000000000000..b0e2c183d02811d5b4fb9b33b6eab8caaafea29f Binary files /dev/null and b/dataset/7/72.png differ diff --git a/dataset/7/74.png b/dataset/7/74.png new file mode 100644 index 0000000000000000000000000000000000000000..4cf5f8f1ea348d72679db53e06fc2b14e2315b92 Binary files /dev/null and b/dataset/7/74.png differ diff --git a/dataset/8/8.png b/dataset/8/8.png new file mode 100644 index 0000000000000000000000000000000000000000..e838116115ff36ff1e3d31eb5996012a465217b4 Binary files /dev/null and b/dataset/8/8.png differ diff --git a/dataset/8/82.png b/dataset/8/82.png new file mode 100644 index 0000000000000000000000000000000000000000..4adb45745620409d05832a9aa6d97c2f54eb4c30 Binary files /dev/null and b/dataset/8/82.png differ diff --git a/dataset/8/83.png b/dataset/8/83.png new file mode 100644 index 0000000000000000000000000000000000000000..9d9acc31e9c5c67c075864dcf4d2df7e682a440e Binary files /dev/null and b/dataset/8/83.png differ diff --git a/dataset/9/91.png b/dataset/9/91.png new file mode 100644 index 0000000000000000000000000000000000000000..3483f2b3d97850b2a756bfda4d9317ceac842b6d Binary files /dev/null and b/dataset/9/91.png differ diff --git a/dataset/9/92.png b/dataset/9/92.png new file mode 100644 index 0000000000000000000000000000000000000000..4f58e8c2eadaa2e9da272bdb150736821d728924 Binary files /dev/null and b/dataset/9/92.png differ diff --git a/dataset/9/94.png b/dataset/9/94.png new file mode 100644 index 0000000000000000000000000000000000000000..11e4be42f6c07e16dad569f93d4205ed51e26b8a Binary files /dev/null and b/dataset/9/94.png differ diff --git a/dataset/A/A (1).png b/dataset/A/A (1).png new file mode 100644 index 0000000000000000000000000000000000000000..8d1e743fd368402c4da4b3cfbdbe0302e24548fd Binary files /dev/null and b/dataset/A/A (1).png differ diff --git a/dataset/A/A2.png b/dataset/A/A2.png new file mode 100644 index 0000000000000000000000000000000000000000..df3b79286062626316cb8934430806e61512b4b3 Binary files /dev/null and b/dataset/A/A2.png differ diff --git a/dataset/A/A3.png b/dataset/A/A3.png new file mode 100644 index 0000000000000000000000000000000000000000..901f19f8c1495b4be1f7847555994e2b9914da5a Binary files /dev/null and b/dataset/A/A3.png differ diff --git a/dataset/A/a.png b/dataset/A/a.png new file mode 100644 index 0000000000000000000000000000000000000000..957c51cb3a210bc79a9ca176abe02381ec15dbb5 Binary files /dev/null and b/dataset/A/a.png differ diff --git a/dataset/B/B.png b/dataset/B/B.png new file mode 100644 index 0000000000000000000000000000000000000000..d558cac7a1e7e09de25062b78a6f2d51198333d6 Binary files /dev/null and b/dataset/B/B.png differ diff --git a/dataset/B/B2.png b/dataset/B/B2.png new file mode 100644 index 0000000000000000000000000000000000000000..9b1917cbe03c4222b24ba40806e2a3eec945fce8 Binary files /dev/null and b/dataset/B/B2.png differ diff --git a/dataset/B/B3.png b/dataset/B/B3.png new file mode 100644 index 0000000000000000000000000000000000000000..ef0251dc2e4346d914c6267300afd544591c8e0d Binary files /dev/null and b/dataset/B/B3.png differ diff --git a/dataset/C/C.png b/dataset/C/C.png new file mode 100644 index 0000000000000000000000000000000000000000..89f010d08c7551462b2cceaf565b803f550184b4 Binary files /dev/null and b/dataset/C/C.png differ diff --git a/dataset/C/C2.png b/dataset/C/C2.png new file mode 100644 index 0000000000000000000000000000000000000000..3c5f602db86e61b5ef700cf5e7ebec9d4bb78808 Binary files /dev/null and b/dataset/C/C2.png differ diff --git a/dataset/C/C3.png b/dataset/C/C3.png new file mode 100644 index 0000000000000000000000000000000000000000..1ac2206c1e4b26a2c22606c197b031bf255377ec Binary files /dev/null and b/dataset/C/C3.png differ diff --git a/dataset/D/D.png b/dataset/D/D.png new file mode 100644 index 0000000000000000000000000000000000000000..0ec4140496e3dbc7cb48987493f3fa1bf1a81ca3 Binary files /dev/null and b/dataset/D/D.png differ diff --git a/dataset/D/D2.png b/dataset/D/D2.png new file mode 100644 index 0000000000000000000000000000000000000000..dbb0bc38b8bec3b02d2b9f093893eb4c0f1c592c Binary files /dev/null and b/dataset/D/D2.png differ diff --git a/dataset/D/D3.png b/dataset/D/D3.png new file mode 100644 index 0000000000000000000000000000000000000000..cc823b5aec880ff9a33b7b7c535d253f349297e7 Binary files /dev/null and b/dataset/D/D3.png differ diff --git a/dataset/D/D4.png b/dataset/D/D4.png new file mode 100644 index 0000000000000000000000000000000000000000..867018f561cbee0242c44db26ca194c724771c4f Binary files /dev/null and b/dataset/D/D4.png differ diff --git a/dataset/E/E (1).png b/dataset/E/E (1).png new file mode 100644 index 0000000000000000000000000000000000000000..8d2cb7da46afb7d48b5612434f896d4a74f3a29f Binary files /dev/null and b/dataset/E/E (1).png differ diff --git a/dataset/E/E2.png b/dataset/E/E2.png new file mode 100644 index 0000000000000000000000000000000000000000..c1bc852e033647ef8a4631a25b045c8f50744676 Binary files /dev/null and b/dataset/E/E2.png differ diff --git a/dataset/E/e.png b/dataset/E/e.png new file mode 100644 index 0000000000000000000000000000000000000000..b84c4491629fd135a87a612444424aa8305f86c8 Binary files /dev/null and b/dataset/E/e.png differ diff --git a/dataset/F/F.png b/dataset/F/F.png new file mode 100644 index 0000000000000000000000000000000000000000..c47059f9af055fcd0453fca1d5e5d482cd47ea6b Binary files /dev/null and b/dataset/F/F.png differ diff --git a/dataset/F/F2.png b/dataset/F/F2.png new file mode 100644 index 0000000000000000000000000000000000000000..dd72fbeb2edcf8fe5a07bf82602b7a3fe67da8db Binary files /dev/null and b/dataset/F/F2.png differ diff --git a/dataset/F/F3.png b/dataset/F/F3.png new file mode 100644 index 0000000000000000000000000000000000000000..50f3a071eeeb848ff7076f180efc62f61ed85a59 Binary files /dev/null and b/dataset/F/F3.png differ diff --git a/dataset/F/F4.png b/dataset/F/F4.png new file mode 100644 index 0000000000000000000000000000000000000000..cfaef7d2d6c655bc848d5fd30eb0ac911028336e Binary files /dev/null and b/dataset/F/F4.png differ diff --git a/dataset/G/G (1).png b/dataset/G/G (1).png new file mode 100644 index 0000000000000000000000000000000000000000..f47af87e789e571cfe1fe185f1d87e8b94f6725c Binary files /dev/null and b/dataset/G/G (1).png differ diff --git a/dataset/G/G2.png b/dataset/G/G2.png new file mode 100644 index 0000000000000000000000000000000000000000..49cddc6deb10d3d5098d019a088e84b779ba1716 Binary files /dev/null and b/dataset/G/G2.png differ diff --git a/dataset/G/G3.png b/dataset/G/G3.png new file mode 100644 index 0000000000000000000000000000000000000000..e8a299d85d0763d67e52339d272b39b7728dc7bc Binary files /dev/null and b/dataset/G/G3.png differ diff --git a/dataset/G/g.png b/dataset/G/g.png new file mode 100644 index 0000000000000000000000000000000000000000..b9b619aecc4d96a9d2b8c9768534e2901ac2f17a Binary files /dev/null and b/dataset/G/g.png differ diff --git a/dataset/H/H.png b/dataset/H/H.png new file mode 100644 index 0000000000000000000000000000000000000000..df7e89340e88a7c3d45d5ae63ccb80ff6289c852 Binary files /dev/null and b/dataset/H/H.png differ diff --git a/dataset/H/H2.png b/dataset/H/H2.png new file mode 100644 index 0000000000000000000000000000000000000000..b46820f520465e7efb7a9a73e4fb012134578109 Binary files /dev/null and b/dataset/H/H2.png differ diff --git a/dataset/H/H3.png b/dataset/H/H3.png new file mode 100644 index 0000000000000000000000000000000000000000..c81769f8659862988411c8051c3f6e9a55610261 Binary files /dev/null and b/dataset/H/H3.png differ diff --git a/dataset/I/I.png b/dataset/I/I.png new file mode 100644 index 0000000000000000000000000000000000000000..91b5731902f68733edfd642136a49bf7d0f4c0e4 Binary files /dev/null and b/dataset/I/I.png differ diff --git a/dataset/I/I2.png b/dataset/I/I2.png new file mode 100644 index 0000000000000000000000000000000000000000..87600ba50a654c146136a111226d99fa51182377 Binary files /dev/null and b/dataset/I/I2.png differ diff --git a/dataset/I/i3.png b/dataset/I/i3.png new file mode 100644 index 0000000000000000000000000000000000000000..061d752c1936b3e5f1795bcb3724ffac3d1653dc Binary files /dev/null and b/dataset/I/i3.png differ diff --git a/dataset/I/i4.png b/dataset/I/i4.png new file mode 100644 index 0000000000000000000000000000000000000000..f64e771cdb32d76d6981827baf2791f8106b373b Binary files /dev/null and b/dataset/I/i4.png differ diff --git a/dataset/J/J.png b/dataset/J/J.png new file mode 100644 index 0000000000000000000000000000000000000000..b2621c64764e079ec6285f9d08eb6173cc8a814c Binary files /dev/null and b/dataset/J/J.png differ diff --git a/dataset/J/J2.png b/dataset/J/J2.png new file mode 100644 index 0000000000000000000000000000000000000000..77b37c5350ff754fb56e63ad8fdde0dcdab8b3c3 Binary files /dev/null and b/dataset/J/J2.png differ diff --git a/dataset/J/J3.png b/dataset/J/J3.png new file mode 100644 index 0000000000000000000000000000000000000000..6b72e9274923e472f066d95a7560b30d3e0cf9d7 Binary files /dev/null and b/dataset/J/J3.png differ diff --git a/dataset/J/J4.png b/dataset/J/J4.png new file mode 100644 index 0000000000000000000000000000000000000000..9ce3d63dd3e2d643d482460f7faa83bfe9308e1a Binary files /dev/null and b/dataset/J/J4.png differ diff --git a/dataset/K/K.png b/dataset/K/K.png new file mode 100644 index 0000000000000000000000000000000000000000..196406df9b7403031a5ebac8927d2dffa4c33d09 Binary files /dev/null and b/dataset/K/K.png differ diff --git a/dataset/K/K2.png b/dataset/K/K2.png new file mode 100644 index 0000000000000000000000000000000000000000..73f99f3e87f983a9fe63a3934f9b6d4822d234e2 Binary files /dev/null and b/dataset/K/K2.png differ diff --git a/dataset/K/k (1).png b/dataset/K/k (1).png new file mode 100644 index 0000000000000000000000000000000000000000..1cccebbfbcfcb0127657c6771451e1bdfdcbfdd8 Binary files /dev/null and b/dataset/K/k (1).png differ diff --git a/dataset/L/L.png b/dataset/L/L.png new file mode 100644 index 0000000000000000000000000000000000000000..66c24c08c99b9e3bd513019c6ef6b24360123976 Binary files /dev/null and b/dataset/L/L.png differ diff --git a/dataset/L/L2.png b/dataset/L/L2.png new file mode 100644 index 0000000000000000000000000000000000000000..4c9a0af8dd75d727643ae4341d85a0a00fad206a Binary files /dev/null and b/dataset/L/L2.png differ diff --git a/dataset/L/L3.png b/dataset/L/L3.png new file mode 100644 index 0000000000000000000000000000000000000000..c4729f425d2634daad944b253fdb021bf744e640 Binary files /dev/null and b/dataset/L/L3.png differ diff --git a/dataset/L/L4.png b/dataset/L/L4.png new file mode 100644 index 0000000000000000000000000000000000000000..771a06f75f1f14dd64b62e8f6c962cdae5ab26a0 Binary files /dev/null and b/dataset/L/L4.png differ diff --git a/dataset/M/M (1).png b/dataset/M/M (1).png new file mode 100644 index 0000000000000000000000000000000000000000..1ee7c05fbe7228437384eb9c4488ddbe80488b82 Binary files /dev/null and b/dataset/M/M (1).png differ diff --git a/dataset/M/m.png b/dataset/M/m.png new file mode 100644 index 0000000000000000000000000000000000000000..76dadfc08fb0137047dfabebdbf9ff9561e37f1f Binary files /dev/null and b/dataset/M/m.png differ diff --git a/dataset/M/m2.png b/dataset/M/m2.png new file mode 100644 index 0000000000000000000000000000000000000000..870dc8d0a56ebdd6f1bf45bd06b44087049e8b95 Binary files /dev/null and b/dataset/M/m2.png differ diff --git a/dataset/N/N (1).png b/dataset/N/N (1).png new file mode 100644 index 0000000000000000000000000000000000000000..ddab93abe032b81346338db5e3d0eeb08581c85e Binary files /dev/null and b/dataset/N/N (1).png differ diff --git a/dataset/N/N2.png b/dataset/N/N2.png new file mode 100644 index 0000000000000000000000000000000000000000..99a9c0d64a7ba634284afc0e0c9aac7b79f2f133 Binary files /dev/null and b/dataset/N/N2.png differ diff --git a/dataset/N/n.png b/dataset/N/n.png new file mode 100644 index 0000000000000000000000000000000000000000..349ac5a62b8e3f948ef6d474fcd0725bb722dac3 Binary files /dev/null and b/dataset/N/n.png differ diff --git a/dataset/O/O.png b/dataset/O/O.png new file mode 100644 index 0000000000000000000000000000000000000000..57c2631a348454cbf673d3ea96ef4d6c0a908a3f Binary files /dev/null and b/dataset/O/O.png differ diff --git a/dataset/O/O2.png b/dataset/O/O2.png new file mode 100644 index 0000000000000000000000000000000000000000..248b9649b62a7af831523e041edee9193fefc257 Binary files /dev/null and b/dataset/O/O2.png differ diff --git a/dataset/O/O3.png b/dataset/O/O3.png new file mode 100644 index 0000000000000000000000000000000000000000..fec64e573ecc97bcb1bf82d3b588a7213a655dd7 Binary files /dev/null and b/dataset/O/O3.png differ diff --git a/dataset/O/o2 (1).png b/dataset/O/o2 (1).png new file mode 100644 index 0000000000000000000000000000000000000000..2fa2b51bea18431814c089b784d820341ac62cd0 Binary files /dev/null and b/dataset/O/o2 (1).png differ diff --git a/dataset/P/P (1).png b/dataset/P/P (1).png new file mode 100644 index 0000000000000000000000000000000000000000..80680b39de5c09dfd215b907009d19c34b8b5f96 Binary files /dev/null and b/dataset/P/P (1).png differ diff --git a/dataset/P/P2.png b/dataset/P/P2.png new file mode 100644 index 0000000000000000000000000000000000000000..4db38b6c9fd95f4774cc8c5a96ac00578049ab93 Binary files /dev/null and b/dataset/P/P2.png differ diff --git a/dataset/P/P4.png b/dataset/P/P4.png new file mode 100644 index 0000000000000000000000000000000000000000..6d6958f9b13f2eed0c7bd1ca50fb96d510d19c21 Binary files /dev/null and b/dataset/P/P4.png differ diff --git a/dataset/P/p.png b/dataset/P/p.png new file mode 100644 index 0000000000000000000000000000000000000000..91fd521a1bda44c2c81234655265c72dc8a96148 Binary files /dev/null and b/dataset/P/p.png differ diff --git a/dataset/Q/Q.png b/dataset/Q/Q.png new file mode 100644 index 0000000000000000000000000000000000000000..fde6e9f2cc6a1b1c9a595bf9a60e47aa500bf353 Binary files /dev/null and b/dataset/Q/Q.png differ diff --git a/dataset/Q/Q2.png b/dataset/Q/Q2.png new file mode 100644 index 0000000000000000000000000000000000000000..8eb7ea5309b436b4940adbbc543894f3e537980e Binary files /dev/null and b/dataset/Q/Q2.png differ diff --git a/dataset/Q/q2 (1).png b/dataset/Q/q2 (1).png new file mode 100644 index 0000000000000000000000000000000000000000..6e4b725284528c622e2361ccd2d14628ed69763c Binary files /dev/null and b/dataset/Q/q2 (1).png differ diff --git a/dataset/Q/q3.png b/dataset/Q/q3.png new file mode 100644 index 0000000000000000000000000000000000000000..9dbf48a71053e171c78b6377d05baf39f63e4f65 Binary files /dev/null and b/dataset/Q/q3.png differ diff --git a/dataset/R/R.png b/dataset/R/R.png new file mode 100644 index 0000000000000000000000000000000000000000..7a4cf7c19b23c6a3b775a6bb9b58de943d551d5d Binary files /dev/null and b/dataset/R/R.png differ diff --git a/dataset/R/R2.png b/dataset/R/R2.png new file mode 100644 index 0000000000000000000000000000000000000000..a3d6ef1755f064a4e8f1d5e00319f2f6227e9824 Binary files /dev/null and b/dataset/R/R2.png differ diff --git a/dataset/R/R3.png b/dataset/R/R3.png new file mode 100644 index 0000000000000000000000000000000000000000..794ea64de8e43c9c1559095fc56a0c0bf2a077ea Binary files /dev/null and b/dataset/R/R3.png differ diff --git a/dataset/R/R4.png b/dataset/R/R4.png new file mode 100644 index 0000000000000000000000000000000000000000..aa8c4b33a6f36db010284ebd4e27c8d6ff7a3191 Binary files /dev/null and b/dataset/R/R4.png differ diff --git a/dataset/S/S (1).png b/dataset/S/S (1).png new file mode 100644 index 0000000000000000000000000000000000000000..ab59309724872667144374a465f876941a005e26 Binary files /dev/null and b/dataset/S/S (1).png differ diff --git a/dataset/S/s.png b/dataset/S/s.png new file mode 100644 index 0000000000000000000000000000000000000000..70d104525e5d92c49cb6b66171171a26b2124682 Binary files /dev/null and b/dataset/S/s.png differ diff --git a/dataset/S/s2.png b/dataset/S/s2.png new file mode 100644 index 0000000000000000000000000000000000000000..821980ea1211d1f81529d72cb879f05caeb8eece Binary files /dev/null and b/dataset/S/s2.png differ diff --git a/dataset/S/s3.png b/dataset/S/s3.png new file mode 100644 index 0000000000000000000000000000000000000000..6712a9f3c20019e9935d07dcdd13659a617ed697 Binary files /dev/null and b/dataset/S/s3.png differ diff --git a/dataset/T/T2.png b/dataset/T/T2.png new file mode 100644 index 0000000000000000000000000000000000000000..e14622f23a7e7572ab60f76b72bbf3dee46e0e47 Binary files /dev/null and b/dataset/T/T2.png differ diff --git a/dataset/T/T4.png b/dataset/T/T4.png new file mode 100644 index 0000000000000000000000000000000000000000..f98f2d4fc81dd65233acb85f8db50eada3fd8f70 Binary files /dev/null and b/dataset/T/T4.png differ diff --git a/dataset/T/t.png b/dataset/T/t.png new file mode 100644 index 0000000000000000000000000000000000000000..16b4a766f0de693bdbf0d3c52ccd16c48e3d6407 Binary files /dev/null and b/dataset/T/t.png differ diff --git a/dataset/T/t2 (1).png b/dataset/T/t2 (1).png new file mode 100644 index 0000000000000000000000000000000000000000..89a3b7ca94449286c4429fa620129fafc88e1ba7 Binary files /dev/null and b/dataset/T/t2 (1).png differ diff --git a/dataset/U/U.png b/dataset/U/U.png new file mode 100644 index 0000000000000000000000000000000000000000..cff1f4200c08ff3ae64f8691bfb663b1354b1983 Binary files /dev/null and b/dataset/U/U.png differ diff --git a/dataset/U/U2.png b/dataset/U/U2.png new file mode 100644 index 0000000000000000000000000000000000000000..5d759aff21c5486e47b2e08d9ca5acfd05ec48b0 Binary files /dev/null and b/dataset/U/U2.png differ diff --git a/dataset/U/U3.png b/dataset/U/U3.png new file mode 100644 index 0000000000000000000000000000000000000000..fd2560341026da1f4d222a1425aa828f49034e9c Binary files /dev/null and b/dataset/U/U3.png differ diff --git a/dataset/U/U4.png b/dataset/U/U4.png new file mode 100644 index 0000000000000000000000000000000000000000..0c5df0cd7a80178e942631be48b98f4a68517f33 Binary files /dev/null and b/dataset/U/U4.png differ diff --git a/dataset/V/V.png b/dataset/V/V.png new file mode 100644 index 0000000000000000000000000000000000000000..05099baf86d9300dd04284b787a77b678ef166a4 Binary files /dev/null and b/dataset/V/V.png differ diff --git a/dataset/V/V2.png b/dataset/V/V2.png new file mode 100644 index 0000000000000000000000000000000000000000..cda1799ad788fee1608111de43cbc92f76a07180 Binary files /dev/null and b/dataset/V/V2.png differ diff --git a/dataset/V/V3.png b/dataset/V/V3.png new file mode 100644 index 0000000000000000000000000000000000000000..9eebb9db414417a831dfff34d060ff66e4647f8e Binary files /dev/null and b/dataset/V/V3.png differ diff --git a/dataset/V/V4.png b/dataset/V/V4.png new file mode 100644 index 0000000000000000000000000000000000000000..feba7481610511f533d34834914e395754b098b4 Binary files /dev/null and b/dataset/V/V4.png differ diff --git a/dataset/V/v5.png b/dataset/V/v5.png new file mode 100644 index 0000000000000000000000000000000000000000..6a9dcf504402c173eefa157e77a452c595c06580 Binary files /dev/null and b/dataset/V/v5.png differ diff --git a/dataset/W/W.png b/dataset/W/W.png new file mode 100644 index 0000000000000000000000000000000000000000..b7481428196b899ced8477ceae864597295af51d Binary files /dev/null and b/dataset/W/W.png differ diff --git a/dataset/W/W2.png b/dataset/W/W2.png new file mode 100644 index 0000000000000000000000000000000000000000..42f33b2d9e7a141575ec0896a14069298140d90c Binary files /dev/null and b/dataset/W/W2.png differ diff --git a/dataset/W/W3.png b/dataset/W/W3.png new file mode 100644 index 0000000000000000000000000000000000000000..5511e27ee080090d19ebe5152952f438dfdd9c34 Binary files /dev/null and b/dataset/W/W3.png differ diff --git a/dataset/W/W4.png b/dataset/W/W4.png new file mode 100644 index 0000000000000000000000000000000000000000..68ae3606bea011330014f092536be1b55415dd2f Binary files /dev/null and b/dataset/W/W4.png differ diff --git a/dataset/X/X.png b/dataset/X/X.png new file mode 100644 index 0000000000000000000000000000000000000000..290d8a3beb7512314afeb239d73a32adabc867f7 Binary files /dev/null and b/dataset/X/X.png differ diff --git a/dataset/X/X2 (1).png b/dataset/X/X2 (1).png new file mode 100644 index 0000000000000000000000000000000000000000..07a13cec47f887ee3fe7132d84bcfa4a1b47d1d0 Binary files /dev/null and b/dataset/X/X2 (1).png differ diff --git a/dataset/X/x2.png b/dataset/X/x2.png new file mode 100644 index 0000000000000000000000000000000000000000..ea0f5f824f3d1e684ec0279da9d0d80ff01b05ea Binary files /dev/null and b/dataset/X/x2.png differ diff --git a/dataset/X/x3.png b/dataset/X/x3.png new file mode 100644 index 0000000000000000000000000000000000000000..8cfc6b226b5c99aa8a761bbafa89e428d2b03c00 Binary files /dev/null and b/dataset/X/x3.png differ diff --git a/dataset/Y/Y.png b/dataset/Y/Y.png new file mode 100644 index 0000000000000000000000000000000000000000..ecd6c5a974c3f51e5c269af5048cb3b5168e7054 Binary files /dev/null and b/dataset/Y/Y.png differ diff --git a/dataset/Y/Y2.png b/dataset/Y/Y2.png new file mode 100644 index 0000000000000000000000000000000000000000..04365a2900e21ad4c1fe837a5be68c87bea2aa91 Binary files /dev/null and b/dataset/Y/Y2.png differ diff --git a/dataset/Y/Y3.png b/dataset/Y/Y3.png new file mode 100644 index 0000000000000000000000000000000000000000..e0691c3fb31ed391bddfad362a784618f09b598a Binary files /dev/null and b/dataset/Y/Y3.png differ diff --git a/dataset/Y/y2 (1).png b/dataset/Y/y2 (1).png new file mode 100644 index 0000000000000000000000000000000000000000..479022e78e43f18c64447776ec202eab190bb80e Binary files /dev/null and b/dataset/Y/y2 (1).png differ diff --git a/dataset/Z/Z.png b/dataset/Z/Z.png new file mode 100644 index 0000000000000000000000000000000000000000..aa46c34bcece8e7e8afb8720e5d23e94c0d0461a Binary files /dev/null and b/dataset/Z/Z.png differ diff --git a/dataset/Z/Z2.png b/dataset/Z/Z2.png new file mode 100644 index 0000000000000000000000000000000000000000..f039f9f7de70c7dcf2d0194de497bc71934be423 Binary files /dev/null and b/dataset/Z/Z2.png differ diff --git a/dataset/Z/Z3.png b/dataset/Z/Z3.png new file mode 100644 index 0000000000000000000000000000000000000000..89c8edd13ad3199b8bbf4acf3bb13340a212124a Binary files /dev/null and b/dataset/Z/Z3.png differ diff --git a/dataset/Z/z4.png b/dataset/Z/z4.png new file mode 100644 index 0000000000000000000000000000000000000000..668245b251b4592b0d29af44fdbb177a3de18646 Binary files /dev/null and b/dataset/Z/z4.png differ diff --git a/dataset/folder_creator.py b/dataset/folder_creator.py new file mode 100644 index 0000000000000000000000000000000000000000..8038a135b3655f1514a9655aae8109b0a66f6229 --- /dev/null +++ b/dataset/folder_creator.py @@ -0,0 +1,17 @@ +import os + +# Define the path where you want to create the folders +base_dir = "C:\DYPIU\___________________CODE___________________\Random Word Genrator\dataset" + +# List of alphabets +alphabets = "0123456789" + +# Loop through each alphabet +for char in alphabets: + # Create folder names based on uppercase and lowercase alphabets + folder_name_upper = os.path.join(base_dir, char.upper()) + folder_name_lower = os.path.join(base_dir, char.lower()) + + # Create folders if they don't exist + os.makedirs(folder_name_upper, exist_ok=True) + os.makedirs(folder_name_lower, exist_ok=True) \ No newline at end of file diff --git a/dataset/samples.jpg b/dataset/samples.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4e1aeb391fb698260047bcd97b488a463772b723 Binary files /dev/null and b/dataset/samples.jpg differ diff --git a/logic.ipynb b/logic.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..9888a6336798b8318fdb247373dd1560c3e6ba36 --- /dev/null +++ b/logic.ipynb @@ -0,0 +1,313 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import random\n", + "from PIL import Image\n", + "import cv2" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "class wordlist:\n", + " def random_word(self):\n", + " alphabates = ['A', 'B', 'C', 'D','E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']\n", + " random_word = random.choice(alphabates)\n", + " return random_word" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "choise = wordlist()\n", + "word = choise.random_word()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A\n" + ] + } + ], + "source": [ + "print(word)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "dataset = \"C:\\DYPIU\\___________________CODE___________________\\Random Word Genrator\\dataset\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "LIST OF FOLDERS" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['0',\n", + " '1',\n", + " '2',\n", + " '3',\n", + " '4',\n", + " '5',\n", + " '6',\n", + " '7',\n", + " '8',\n", + " '9',\n", + " 'A',\n", + " 'B',\n", + " 'C',\n", + " 'D',\n", + " 'E',\n", + " 'F',\n", + " 'G',\n", + " 'H',\n", + " 'I',\n", + " 'J',\n", + " 'K',\n", + " 'L',\n", + " 'M',\n", + " 'N',\n", + " 'O',\n", + " 'P',\n", + " 'Q',\n", + " 'R',\n", + " 'S',\n", + " 'T',\n", + " 'U',\n", + " 'V',\n", + " 'W',\n", + " 'X',\n", + " 'Y',\n", + " 'Z']" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "folders = [folder for folder in os.listdir(dataset) if os.path.isdir(os.path.join(dataset, folder))]\n", + "folders" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "FOR RANDOM FOLDER SELECTION" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [], + "source": [ + "random_folder = random.choice(folders)" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['F.png', 'F2.png', 'F3.png', 'F4.png']" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "images = [img for img in os.listdir(os.path.join(dataset, random_folder)) if img.endswith(\".jpg\") or img.endswith(\".png\")]\n", + "images" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [], + "source": [ + "random_image = random.choice(images)" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [], + "source": [ + "image_path = os.path.join(dataset, random_folder, random_image)\n", + "image = cv2.imread(image_path)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [], + "source": [ + "cv2.imshow(\"Random Image\", image)\n", + "cv2.waitKey(0)\n", + "cv2.destroyAllWindows()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "MAIN LOGIC\n" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [], + "source": [ + "word = input(\"Enter a word: \").upper()" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [], + "source": [ + "# Create an empty list to store resized images\n", + "resized_images = []\n", + "\n", + "# Iterate over each letter in the word\n", + "for letter in word:\n", + " # Check if the folder corresponding to the letter exists\n", + " letter_folder_path = os.path.join(dataset, letter)\n", + " if os.path.isdir(letter_folder_path):\n", + " # Get list of image files in the folder\n", + " images_in_folder = [img for img in os.listdir(letter_folder_path) if img.endswith(\".jpg\") or img.endswith(\".png\")]\n", + "\n", + " if images_in_folder:\n", + " # Randomly select an image from the folder\n", + " random_image_name = random.choice(images_in_folder)\n", + " # Construct the path to the randomly selected image\n", + " image_path = os.path.join(letter_folder_path, random_image_name)\n", + "\n", + " # Read the image using OpenCV\n", + " image = cv2.imread(image_path)\n", + " # Resize the image to 250x250 pixels\n", + " resized_image = cv2.resize(image, (250, 250))\n", + " resized_images.append(resized_image)\n", + " else:\n", + " print(\"No images found for the letter:\", letter)\n", + " else:\n", + " print(\"Folder not found for the letter:\", letter)" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Concatenated image saved successfully as: output_folder\\concatenated_image.jpg\n" + ] + } + ], + "source": [ + "if resized_images:\n", + " concatenated_images = cv2.hconcat(resized_images)\n", + "\n", + " # Display the concatenated image in a window\n", + " cv2.imshow(\"Concatenated Images\", concatenated_images)\n", + " cv2.waitKey(0)\n", + " cv2.destroyAllWindows()\n", + "\n", + " # Save the concatenated image\n", + " output_folder = \"output_folder\"\n", + " if not os.path.exists(output_folder):\n", + " os.makedirs(output_folder)\n", + " output_image_path = os.path.join(output_folder, \"concatenated_image.jpg\")\n", + " cv2.imwrite(output_image_path, concatenated_images)\n", + " print(\"Concatenated image saved successfully as:\", output_image_path)\n", + "else:\n", + " print(\"No images found for the input word.\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.11.1" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/temp.ipynb b/temp.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..03b3158789a0e89ccb33e29332a804e3f8822710 --- /dev/null +++ b/temp.ipynb @@ -0,0 +1,159 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Running on local URL: http://127.0.0.1:7863\n", + "Running on public URL: https://106ff53aeff217d73d.gradio.live\n", + "\n", + "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n" + ] + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import os\n", + "import random\n", + "import cv2\n", + "import gradio as gr\n", + "from PIL import Image\n", + "import numpy as np\n", + "\n", + "def generate_and_delete_word_image(word):\n", + " \"\"\"Generates a combined image, displays it, and deletes it afterward.\n", + "\n", + " Args:\n", + " word: The user-provided word (uppercase).\n", + "\n", + " Returns:\n", + " The image data for displaying.\n", + " \"\"\"\n", + "\n", + " dataset_path = \"C:\\DYPIU\\___________________CODE___________________\\Random Word Genrator\\dataset\" # Adjust for your dataset path\n", + "\n", + " resized_images = []\n", + " for letter in word:\n", + " letter_folder_path = os.path.join(dataset_path, letter)\n", + "\n", + " # Check if the folder exists\n", + " if not os.path.isdir(letter_folder_path):\n", + " print(\"Folder not found for the letter:\", letter)\n", + " continue\n", + "\n", + " images_in_folder = [img for img in os.listdir(letter_folder_path)\n", + " if img.endswith(\".jpg\") or img.endswith(\".png\")]\n", + "\n", + " if not images_in_folder:\n", + " print(\"No images found for the letter:\", letter)\n", + " continue\n", + "\n", + " # Randomly select an image from the folder\n", + " random_image_name = random.choice(images_in_folder)\n", + " image_path = os.path.join(letter_folder_path, random_image_name)\n", + "\n", + " try:\n", + " # Load image using PIL, ensuring RGB mode\n", + " image = Image.open(image_path).convert(\"RGB\")\n", + " # Convert to NumPy array for OpenCV\n", + " resized_image = np.array(image.resize((250, 250)))\n", + " except Exception as e:\n", + " print(f\"Error loading image: {e}\")\n", + " continue\n", + "\n", + " resized_images.append(resized_image)\n", + "\n", + " if not resized_images:\n", + " print(\"No images found for the input word.\")\n", + " return None\n", + "\n", + " concatenated_image = cv2.hconcat(resized_images)\n", + "\n", + " # Display the concatenated image\n", + " # cv2.imshow(\"Concatenated Image\", concatenated_image)\n", + " # cv2.waitKey(0)\n", + " # cv2.destroyAllWindows()\n", + "\n", + " # Return the image data\n", + " return concatenated_image\n", + "\n", + "# Gradio interface with clear explanations\n", + "interface = gr.Interface(\n", + " fn=generate_and_delete_word_image,\n", + " inputs=\"text\", # User input for the word\n", + " outputs=\"image\", # Output as an image\n", + " title=\"Random Word Image Generator\",\n", + " description=\"Enter a word (uppercase letters only) to generate a combined image using random letters from the dataset. The image will be displayed below.\",\n", + " \n", + " \n", + " css=\"\"\"\n", + " body {\n", + " background-color: white;\n", + " font-family: Arial, sans-serif;\n", + " }\n", + " .gr-interactive-component h1 {\n", + " font-size: 20px;\n", + " margin-bottom: 10px;\n", + " }\n", + " \"\"\",\n", + " \n", + ")\n", + "\n", + "\n", + "interface.launch(share=True) # Launch the Gradio interface and share it publicly\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.11.1" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}