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
2107e3b4
Commit
2107e3b4
authored
Jul 17, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update predict
parent
bd337fb8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
Arial-Unicode.ttf
font/Arial-Unicode.ttf
+0
-0
predict.py
predict.py
+6
-5
util.py
util.py
+10
-0
No files found.
font/Arial-Unicode.ttf
deleted
100644 → 0
View file @
bd337fb8
File deleted
predict.py
View file @
2107e3b4
...
...
@@ -4,7 +4,7 @@
from
cog
import
BasePredictor
,
Input
,
Path
from
typing
import
List
from
modelscope.pipelines
import
pipeline
from
util
import
save_images
,
read_im
ages_in_folder
from
util
import
save_images
,
read_im
g_result
img_save_folder
=
"SaveImages"
params
=
{
...
...
@@ -33,7 +33,7 @@ class Predictor(BasePredictor):
description
=
""
,
default
=
'https://replicate.delivery/pbxt/0eNDe5B73njlkkSJfJeZ4Riiww3OYci679bnbaf0cNzLh2tRC/image_1.png'
),
use_fp32
:
bool
=
Input
(
description
=
""
,
default
=
False
),
no_translator
:
bool
=
Input
(
description
=
""
,
default
=
False
),
)
->
List
[
Path
]:
)
->
List
[
str
]:
input_data
=
{}
if
mode
==
"text-generation"
:
input_data
=
{
...
...
@@ -58,8 +58,9 @@ class Predictor(BasePredictor):
if
rtn_warning
:
print
(
rtn_warning
)
return
[]
res
=
[]
if
rtn_code
>=
0
:
save_images
(
results
,
img_save_folder
)
res
=
read_img_result
(
results
)
# save_images(results, img_save_folder)
print
(
f
'Done, result images are saved in: {img_save_folder}'
)
images
=
read_images_in_folder
(
img_save_folder
)
return
images
return
res
util.py
View file @
2107e3b4
...
...
@@ -42,6 +42,16 @@ def save_images(img_list, folder):
cv2
.
imwrite
(
save_path
,
img
[
...
,
::
-
1
])
def
read_img_result
(
img_list
):
res
=
[]
for
_
,
img
in
enumerate
(
img_list
):
_
,
img_encoded
=
cv2
.
imencode
(
'.jpg'
,
img
)
# Encode image as base64
base64_encoded
=
base64
.
b64encode
(
img_encoded
)
.
decode
(
'utf-8'
)
res
.
append
(
base64_encoded
)
return
res
def
check_channels
(
image
):
channels
=
image
.
shape
[
2
]
if
len
(
image
.
shape
)
==
3
else
1
if
channels
==
1
:
...
...
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