Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cog-anytext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanjinfei
cog-anytext
Commits
d65ced0b
Commit
d65ced0b
authored
Jul 17, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Anytext
parent
6cb264b6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
11 deletions
+5
-11
dataset_util.py
dataset_util.py
+4
-8
predict.py
predict.py
+1
-3
No files found.
dataset_util.py
View file @
d65ced0b
...
@@ -14,8 +14,7 @@ def load(file_path: str):
...
@@ -14,8 +14,7 @@ def load(file_path: str):
def
load_txt
(
file_path
:
str
):
def
load_txt
(
file_path
:
str
):
with
open
(
file_path
,
'r'
,
encoding
=
'utf8'
)
as
f
:
with
open
(
file_path
,
'r'
,
encoding
=
'utf8'
)
as
f
:
content
=
[
x
.
strip
()
.
strip
(
'
\ufeff
'
)
.
strip
(
'
\xef\xbb\xbf
'
)
content
=
[
x
.
strip
()
.
strip
(
'
\ufeff
'
)
.
strip
(
'
\xef\xbb\xbf
'
)
for
x
in
f
.
readlines
()]
for
x
in
f
.
readlines
()]
return
content
return
content
...
@@ -57,13 +56,10 @@ def show_bbox_on_image(image, polygons=None, txt=None, color=None, font_path='./
...
@@ -57,13 +56,10 @@ def show_bbox_on_image(image, polygons=None, txt=None, color=None, font_path='./
for
i
,
box
in
enumerate
(
polygons
):
for
i
,
box
in
enumerate
(
polygons
):
box
=
box
[
0
]
box
=
box
[
0
]
if
txt
is
not
None
:
if
txt
is
not
None
:
draw
.
text
((
int
(
box
[
0
][
0
])
+
20
,
int
(
box
[
0
][
1
])
-
20
),
draw
.
text
((
int
(
box
[
0
][
0
])
+
20
,
int
(
box
[
0
][
1
])
-
20
),
str
(
txt
[
i
]),
fill
=
'red'
,
font
=
font
)
str
(
txt
[
i
]),
fill
=
'red'
,
font
=
font
)
for
j
in
range
(
len
(
box
)
-
1
):
for
j
in
range
(
len
(
box
)
-
1
):
draw
.
line
((
box
[
j
][
0
],
box
[
j
][
1
],
box
[
j
+
1
][
0
],
draw
.
line
((
box
[
j
][
0
],
box
[
j
][
1
],
box
[
j
+
1
][
0
],
box
[
j
+
1
][
1
]),
fill
=
color
,
width
=
2
)
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
[
-
1
][
0
],
box
[
-
1
][
1
],
box
[
0
][
0
],
box
[
0
][
1
]),
fill
=
color
,
width
=
2
)
return
image
return
image
...
...
predict.py
View file @
d65ced0b
# Prediction interface for Cog ⚙️
# Prediction interface for Cog ⚙️
# https://cog.run/python
# https://cog.run/python
from
modelscope
import
snapshot_download
from
cog
import
BasePredictor
,
Input
,
Path
from
cog
import
BasePredictor
,
Input
,
Path
from
typing
import
List
from
typing
import
List
from
modelscope.pipelines
import
pipeline
from
modelscope.pipelines
import
pipeline
...
@@ -17,9 +16,8 @@ params = {
...
@@ -17,9 +16,8 @@ params = {
class
Predictor
(
BasePredictor
):
class
Predictor
(
BasePredictor
):
def
setup
(
self
)
->
None
:
def
setup
(
self
)
->
None
:
model_dir
=
snapshot_download
(
'iic/cv_anytext_text_generation_editing'
)
self
.
model
=
pipeline
(
'my-anytext-task'
,
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
(
def
predict
(
self
,
self
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment