manh08 commited on
Commit
5eb88a1
verified
1 Parent(s): 78f2690

upload test_part1.py

Browse files
Files changed (1) hide show
  1. test_part1.py +28 -0
test_part1.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dotenv import find_dotenv, load_dotenv
2
+ from transformers import pipeline
3
+ # from langchain import PromptTemplate, LLMChain, OpenAI
4
+ from langchain_openai import ChatOpenAI
5
+ from langchain.prompts import PromptTemplate
6
+ from langchain.chains import LLMChain
7
+ from langchain_openai import ChatOpenAI
8
+ import requests
9
+ import os
10
+
11
+ load_dotenv(find_dotenv())
12
+ # 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 = os.getenv("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")
13
+
14
+ # openai_api_key = os.getenv("OPENAI_API_KEY")
15
+
16
+ # if openai_api_key is None:
17
+ # raise ValueError("Kh贸a API OPENAI_API_KEY kh么ng t矛m th岷. Vui l貌ng ki峄僲 tra file .env.")
18
+
19
+ # img2text
20
+ def img2text(url):
21
+ image_to_text = pipeline("image-to-text", model = "Salesforce/blip-image-captioning-large")
22
+
23
+ text = image_to_text(url)[0]["generated_text"]
24
+
25
+ print(text)
26
+ return text
27
+
28
+ img2text("Blackpink.png")