gpt-4o에 해당하는 글 3

GPT 4o Vision 활용하기(3)

AI주식자동매매|2024. 10. 6. 14:36
반응형

안녕하세요? 

이번에는  ChatGPT Vision을 어떤 곳에서 활용할 수 있을까를 생각해 봤습니다.

이 글을 읽으신 분들도 한번 같이 생각해 봐 주시고, 의견 달아주시면 정말 감사하겠습니다.

 

1) 주식 차트정보를 보여주고, 이 주식 매수해도 될지 ChtGPT에게 물어보기

    - 제가 지금 API를 통해서 구현하면서 얼마나 정확성이 있는지 테스트 해보고 있는 방법이죠.

      GPT 4o Vision 활용하기(1)을 참조해 주세요.

 

2) 인물 사진을 보여주고, 누구인지, 어디사는 사람인지, 한국인인지 일본인지, 중국인지 등 물어볼 수 있겠죠?

 

3) 식물, 동물 사진 보여주고, 식물이름이나, 동물이름, 해조류 이름 등 맞추기

 

4) 분해되어 있거나, 아직 조립하지 않은 물건을 어떻게 조립하면 될지 물어볼수도 있겠죠?

 

5) 생산제품 외관사진을 보여주고 불량인지 아닌지 판별해 달라고 할 수 도 있겠죠?

 

6) 두장의 사진을 비교해서 보여주고, 어떤 문제가 있는지 분석요청도 할 수 있겠죠?

 

7) 어떤 사고현장 사진을 보여주고, 현 상황을 설명하게 하고, 119나 112에 전화하는 기능과 연결할 수도 있겠죠?

 

이 밖에 다양하게 인공지능 생성형 AI Vision 기능을 통해서 할 수 있는 일들이 무궁무진할 것 같긴합니다.

여러분들은 어떤 곳에서 사용될 수 있을거라고 생각하시나요?

 

반응형

댓글()

GPT 4o Vision 활용하기(2)

AI주식자동매매|2024. 10. 6. 14:25
반응형

이번에는 ChatGPT Vision을 사용할 경우, 각 버젼별 비용을 알아볼거에요.

 

1) GPT-4o( GPT-4o-2024-05-13 )

    1일 사용 token 2,292,425 token(input&output)

    1일 사용 Cost 11.52$

    ------------------------------

     1 token당 약 0.006784원(Won) => 1회당 약 300 token 사용한다고 할때, 1회 API요청시 약 2원이 사용됨.

9월25일 Activity Tokens
9월25일 Costs

2) GPT-4o-mini GPT-4o-2024-05-13

    1일 사용 token 146,851,547 token(input&output)

    1일 사용 Cost 22.04$

     ------------------------------

     1 token당 약 0.0002026원 => 1회당 약 300 token 사용한다고 할때, 1회 API요청시 약 0.06원이 사용됨.

9/25일 Activity Tokens

   

9월25일 Costs

 

결국, GPT-4o는 GPT-4o-mini보다 약 33배 비싸다고 할 수 있겠네요.

 

이용에 참조하세요.

반응형

댓글()

GPT 4o Vision 활용하기

카테고리 없음|2024. 9. 25. 06:34
반응형

이미지를 호출하여 encode 하고, openapi 호출하기

# 이미지를 저장할 폴더 이름
folder_name = 'image'
# 저장할 파일의 경로를 설정. 여기서는 'image/파일명.jpg' 형식을 사용합니다.
image_path = os.path.join(folder_name, stockCode + "_" + current_date_str + ".jpg")
# Getting the base64 string
base64_image = self.encode_image(image_path=image_path)
description = self.describe_image(api_key=self.openai_secret_key, base64_image=base64_image)
# print(f"이미지 설명: {description}")
if description is None:
    # text = "gpt-4o-mini 검증 실패"
    # self.ui.pteLog.appendPlainText("%s(%s) %s" % (stockName, stockCode, text))
    market_trand = 0
elif 'No' in description:  # Case-insensitive check for 'No'
    text = "%s(%s) gpt-4o vision says %s" % (stockName, stockCode, description)
    self.ui.pteLog.appendPlainText(text)
    market_trand = 0
elif 'Yes' in description:  # Case-insensitive check for 'Yes'
    text = "%s(%s) gpt-4o vision says %s" % (stockName, stockCode, description)
    self.ui.pteLog.appendPlainText(text)
    market_trand = 5
else:
    # text = "%s(%s) gpt-4o vision says %s" % (stockName, stockCode, description)
    # self.ui.pteLog.appendPlainText(text)
    market_trand = 0

 

사용된 함수들

# Function to encode the image
def encode_image(self, image_path=''):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode('utf-8')

def describe_image(self, api_key='', base64_image=''):  # GPT-4 Vision 모델용
    """
    GPT-4 Vision 모델을 사용하여 이미지를 설명하는 함수
    """
    # print("GPT-4 Vision 모델을 사용하여 이미지를 설명하는 함수")
    try:
        headers = {
            "Content-Type": "application/json",
            "Authorization": f"Bearer {api_key}"
        }

        payload = {
            "model": "gpt-4o",  # "model": "gpt-4o-mini",
            "messages": [
                {
                    "role": "user",
                    "content": [
                        {
                            "type": "text",
                            "text": "If the price is holding support and showing signs of upward momentum, it might be a good time to buy, right? Look at the left-side day chart and right-side 5-minute chart. After closing inspection of the 5-minute chart, Please say 'Yes' if you sure it is fully and clearly transitioned into an upward trend momentum. if not, say No."
                        },
                        {
                            "type": "image_url",
                            "image_url": {
                                "url": f"data:image/jpeg;base64,{base64_image}"
                            }
                        }
                    ]
                }
            ],
            "max_tokens": 300
        }
    except Exception as e:
        print("GPT-4 Vision 모델을 사용하여 이미지를 설명: %s" % e)
        return None
    response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
    # print(response.json())
    # Parse the JSON response
    response_data = response.json()
    # Print only the 'choices' part
    choices = response_data.get('choices', [])
    if choices:
        content = choices[0]['message']['content']
        # print(content)
        return content
    else:
        print("No content found.")
        return None

 

Telegram Bot을 통해 결과 확인.

반응형

댓글()