File size: 4,703 Bytes
1e6ccdc |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"์ด๋ฏธ์ง ๋ถ์ ์ค...\n",
"\n",
"์์ด ๋ถ์ ๊ฒฐ๊ณผ:\n",
"\n",
"The painting features a couple passionately embracing, set against a rich, gold-leaf background. The figures are depicted in a stylized manner, with elongated bodies and flowing hair. The woman's face is partially obscured by a veil, adding a sense of mystery and intrigue to the composition. The man's face is turned towards the woman, his eyes closed in a moment of intimacy. The couple's bodies are intertwined, creating a sense of unity and connection. The use of gold leaf throughout the painting adds a luxurious and ethereal quality, enhancing the overall romantic atmosphere of the piece. The intricate patterns and textures in the background further emphasize the couple's connection and the overall sense of opulence and beauty in the painting.\n",
"\n",
"ํ๊ตญ์ด๋ก ๋ฒ์ญ ์ค...\n",
"\n",
"ํ๊ตญ์ด ๋ฒ์ญ ๊ฒฐ๊ณผ:\n",
"\n",
"์ด ๊ทธ๋ฆผ์ ํ๋ถํ ๊ธ๋ฐ์ ๋ฐฐ๊ฒฝ์ผ๋ก ์ด์ ์ ์ผ๋ก ํฌ์นํ๋ ๋ถ๋ถ์ ๋ชจ์ต์ ๋ด๊ณ ์์ต๋๋ค. ์ธ๋ฌผ์ ๊ธธ์ญํ ๋ชธ๊ณผ ํ๋ฅด๋ ๋จธ๋ฆฌ์นด๋ฝ์ผ๋ก ์์ํ๋ ๋ฐฉ์์ผ๋ก ๋ฌ์ฌ๋์ด ์์ต๋๋ค. ์ฌ์ฑ์ ์ผ๊ตด์ ๋ฒ ์ผ๋ก ๋ถ๋ถ์ ์ผ๋ก ๊ฐ๋ ค์ ธ ์์ด ๊ตฌ๋์ ์ ๋น๊ฐ๊ณผ ์๋ชจ๋ฅผ ๋ํฉ๋๋ค. ๋จ์์ ์ผ๊ตด์ ์ฌ์ ์ชฝ์ผ๋ก ํฅํ๊ณ ์์ผ๋ฉฐ, ์น๋ฐ๊ฐ์ ๋๋ผ๋ฉฐ ๋์ ๊ฐ๊ณ ์์ต๋๋ค. ๋ ์ฌ๋์ ๋ชธ์ ์๋ก ์ฝํ ์์ด ์ผ์ฒด๊ฐ๊ณผ ์ฐ๊ฒฐ๊ฐ์ ์์๋
๋๋ค. ๊ทธ๋ฆผ ์ ์ฒด์ ๊ธ๋ฐ์ ์ฌ์ฉํ์ฌ ๊ณ ๊ธ์ค๋ฝ๊ณ ๋ฏธ๋ฌํ ๋๋์ ๋ํ์ฌ ์ํ์ ์ ์ฒด์ ์ธ ๋ก๋งจํฑํ ๋ถ์๊ธฐ๋ฅผ ๋์ฑ ๋๋ณด์ด๊ฒ ํฉ๋๋ค. ๋ฐฐ๊ฒฝ์ ๋ณต์กํ ํจํด๊ณผ ์ง๊ฐ์ ๋ถ๋ถ์ ์ฐ๊ฒฐ๊ณผ ๊ทธ๋ฆผ์ ์ ๋ฐ์ ์ธ ํ๋ คํจ๊ณผ ์๋ฆ๋ค์์ ๋์ฑ ๊ฐ์กฐํฉ๋๋ค.\n"
]
}
],
"source": [
"import requests\n",
"import base64\n",
"import deepl\n",
"\n",
"# RunPod API ์ค์ \n",
"runpod_url = \"https://api.runpod.ai/v2/qkqui1t394hjws/runsync\"\n",
"runpod_headers = {\n",
" \"Authorization\": \"C51NZTZUOIPSB3NNECOGREZLBHGTZL13FW9L6U5Y\",\n",
" \"Content-Type\": \"application/json\"\n",
"}\n",
"\n",
"# DeepL API ์ค์ \n",
"deepl_auth_key = \"fb94505a-9cf7-40cc-95af-8513f31794d1:fx\"\n",
"\n",
"def encode_image(image_path):\n",
" with open(image_path, \"rb\") as image_file:\n",
" return base64.b64encode(image_file.read()).decode('utf-8')\n",
"\n",
"def analyze_image(image_path):\n",
" base64_image = encode_image(image_path)\n",
" data = {\n",
" \"input\": {\n",
" \"max_new_tokens\": 512,\n",
" \"category\": \"General Visual Analysis\",\n",
" \"image\": base64_image\n",
" }\n",
" }\n",
" response = requests.post(runpod_url, headers=runpod_headers, json=data)\n",
" if response.status_code == 200:\n",
" return response.json()['output']['result']\n",
" else:\n",
" return f\"์ด๋ฏธ์ง ๋ถ์ ์คํจ. ์ํ ์ฝ๋: {response.status_code}\"\n",
"\n",
"def translate_en_to_ko(text):\n",
" translator = deepl.Translator(deepl_auth_key)\n",
" try:\n",
" result = translator.translate_text(text, target_lang=\"KO\")\n",
" return result.text\n",
" except deepl.DeepLException as e:\n",
" return f\"๋ฒ์ญ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}\"\n",
"\n",
"def main():\n",
" image_path = r\"C:\\Users\\user\\Desktop\\GemmArte-main\\dataset\\images\\2.png\"\n",
" \n",
" print(\"์ด๋ฏธ์ง ๋ถ์ ์ค...\")\n",
" analysis_result = analyze_image(image_path)\n",
" print(\"\\n์์ด ๋ถ์ ๊ฒฐ๊ณผ:\")\n",
" print(analysis_result)\n",
"\n",
" print(\"\\nํ๊ตญ์ด๋ก ๋ฒ์ญ ์ค...\")\n",
" korean_result = translate_en_to_ko(analysis_result)\n",
" print(\"\\nํ๊ตญ์ด ๋ฒ์ญ ๊ฒฐ๊ณผ:\")\n",
" print(korean_result)\n",
"\n",
"if __name__ == \"__main__\":\n",
" main()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "nlp",
"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.10"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|