Commit d65ced0b authored by duanjinfei's avatar duanjinfei

add Anytext

parent 6cb264b6
......@@ -14,8 +14,7 @@ def load(file_path: str):
def load_txt(file_path: str):
with open(file_path, 'r', encoding='utf8') as f:
content = [x.strip().strip('\ufeff').strip('\xef\xbb\xbf')
for x in f.readlines()]
content = [x.strip().strip('\ufeff').strip('\xef\xbb\xbf') for x in f.readlines()]
return content
......@@ -57,13 +56,10 @@ def show_bbox_on_image(image, polygons=None, txt=None, color=None, font_path='./
for i, box in enumerate(polygons):
box = box[0]
if txt is not None:
draw.text((int(box[0][0]) + 20, int(box[0][1]) - 20),
str(txt[i]), fill='red', font=font)
draw.text((int(box[0][0]) + 20, int(box[0][1]) - 20), str(txt[i]), fill='red', font=font)
for j in range(len(box) - 1):
draw.line((box[j][0], box[j][1], box[j + 1][0],
box[j + 1][1]), fill=color, width=2)
draw.line((box[-1][0], box[-1][1], box[0][0],
box[0][1]), fill=color, width=2)
draw.line((box[j][0], box[j][1], box[j + 1][0], box[j + 1][1]), fill=color, width=2)
draw.line((box[-1][0], box[-1][1], box[0][0], box[0][1]), fill=color, width=2)
return image
......
# Prediction interface for Cog ⚙️
# https://cog.run/python
from modelscope import snapshot_download
from cog import BasePredictor, Input, Path
from typing import List
from modelscope.pipelines import pipeline
......@@ -17,9 +16,8 @@ params = {
class Predictor(BasePredictor):
def setup(self) -> None:
model_dir = snapshot_download('iic/cv_anytext_text_generation_editing')
self.model = pipeline('my-anytext-task',
model=model_dir, model_revision='v1.1.3')
model='damo/cv_anytext_text_generation_editing', model_revision='v1.1.3')
def predict(
self,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment