rogerxavier
commited on
Commit
•
b8fdce1
1
Parent(s):
2f83ae5
Update 3mergeDialogToVideo.py
Browse files- 3mergeDialogToVideo.py +19 -18
3mergeDialogToVideo.py
CHANGED
@@ -206,28 +206,29 @@ def sort_dialog_list(sorted_indices:list,related_groups:list,sorted_coordinates)
|
|
206 |
|
207 |
def get_sorted_dialog_text(image_path:"包含后缀的文件路径")->"返回排序后的text list(一列或者几列话,反正是一个框的内容,几句不清楚,一个框的list当一次文案就行) 或者失败请求返回none":
|
208 |
image_bytes = open(image_path, 'rb')
|
209 |
-
headers = {
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
}
|
226 |
files = {
|
227 |
"image": image_bytes,
|
228 |
}
|
229 |
try:
|
230 |
-
resp = requests.post("https://rogerxavier-ocr-with-fastapi.hf.space/getCoordinates", files=files,headers=headers)#还是有header才能跑
|
|
|
231 |
#先json转换,0为坐标list合集,1为 boxid和text合集
|
232 |
boxCoordinates , boxInfo = resp.json()[0],resp.json()[1] #分别是list和dict类型
|
233 |
print("ofa ocr识别漫画块成功返回")
|
|
|
206 |
|
207 |
def get_sorted_dialog_text(image_path:"包含后缀的文件路径")->"返回排序后的text list(一列或者几列话,反正是一个框的内容,几句不清楚,一个框的list当一次文案就行) 或者失败请求返回none":
|
208 |
image_bytes = open(image_path, 'rb')
|
209 |
+
# headers = {
|
210 |
+
# 'authority': 'rogerxavier-fastapi-t5-magi.hf.space',
|
211 |
+
# 'scheme': 'https',
|
212 |
+
# 'Accept': '*/*',
|
213 |
+
# 'Accept-Encoding': 'gzip, deflate, br, zstd',
|
214 |
+
# 'Accept-Language': 'zh-CN,zh;q=0.9',
|
215 |
+
# 'Cookie': 'spaces-jwt=eyJhbGciOiJFZERTQSJ9.eyJyZWFkIjp0cnVlLCJwZXJtaXNzaW9ucyI6eyJyZXBvLmNvbnRlbnQucmVhZCI6dHJ1ZX0sIm9uQmVoYWxmT2YiOnsia2luZCI6InVzZXIiLCJfaWQiOiI2NDJhNTNiNTE2ZDRkODI5M2M5YjdiNzgiLCJ1c2VyIjoicm9nZXJ4YXZpZXIifSwiaWF0IjoxNzE2Njg3MzU3LCJzdWIiOiIvc3BhY2VzL3JvZ2VyeGF2aWVyL29jcl93aXRoX2Zhc3RhcGkiLCJleHAiOjE3MTY3NzM3NTcsImlzcyI6Imh0dHBzOi8vaHVnZ2luZ2ZhY2UuY28ifQ._sGdEgC-ijbIhLmB6iNSBQ_xHNzb4Ydb9mD0L3ByRmJSbB9ccfGbRgtNmkV1JLLldHp_VEKUSQt9Mwq_q4aGAQ',
|
216 |
+
# 'Dnt': '1',
|
217 |
+
# 'Priority': 'u=1, i',
|
218 |
+
# 'Sec-Ch-Ua': '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
219 |
+
# 'Sec-Ch-Ua-Mobile': '?0',
|
220 |
+
# 'Sec-Ch-Ua-Platform': '"Windows"',
|
221 |
+
# 'Sec-Fetch-Dest': 'empty',
|
222 |
+
# 'Sec-Fetch-Mode': 'cors',
|
223 |
+
# 'Sec-Fetch-Site': 'same-origin',
|
224 |
+
# 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
|
225 |
+
# }
|
226 |
files = {
|
227 |
"image": image_bytes,
|
228 |
}
|
229 |
try:
|
230 |
+
# resp = requests.post("https://rogerxavier-ocr-with-fastapi.hf.space/getCoordinates", files=files,headers=headers)#还是有header才能跑
|
231 |
+
resp = requests.post("https://rogerxavier-ocr-with-fastapi.hf.space/getCoordinates", files=files)#不用header看看会不会还限制
|
232 |
#先json转换,0为坐标list合集,1为 boxid和text合集
|
233 |
boxCoordinates , boxInfo = resp.json()[0],resp.json()[1] #分别是list和dict类型
|
234 |
print("ofa ocr识别漫画块成功返回")
|