Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
5a692278
Unverified
Commit
5a692278
authored
Apr 23, 2024
by
Sayak Paul
Committed by
GitHub
Apr 23, 2024
Browse files
[Metadat utils] fix: json lines ordering. (#7744)
fix: json lines ordering.
parent
fc9fecc2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
utils/update_metadata.py
utils/update_metadata.py
+22
-3
No files found.
utils/update_metadata.py
View file @
5a692278
...
...
@@ -30,7 +30,7 @@ import tempfile
import
pandas
as
pd
from
datasets
import
Dataset
from
huggingface_hub
import
upload_folder
from
huggingface_hub
import
hf_hub_download
,
upload_folder
from
diffusers.pipelines.auto_pipeline
import
(
AUTO_IMAGE2IMAGE_PIPELINES_MAPPING
,
...
...
@@ -39,6 +39,9 @@ from diffusers.pipelines.auto_pipeline import (
)
PIPELINE_TAG_JSON
=
"pipeline_tags.json"
def
get_supported_pipeline_table
()
->
dict
:
"""
Generates a dictionary containing the supported auto classes for each pipeline type,
...
...
@@ -57,8 +60,8 @@ def get_supported_pipeline_table() -> dict:
(
class_name
.
__name__
,
"image-to-image"
,
"AutoPipelineForInpainting"
)
for
_
,
class_name
in
AUTO_INPAINT_PIPELINES_MAPPING
.
items
()
]
all_supported_pipeline_classes
.
sort
(
key
=
lambda
x
:
x
[
0
])
all_supported_pipeline_classes
=
list
(
set
(
all_supported_pipeline_classes
))
all_supported_pipeline_classes
.
sort
(
key
=
lambda
x
:
x
[
0
])
data
=
{}
data
[
"pipeline_class"
]
=
[
sample
[
0
]
for
sample
in
all_supported_pipeline_classes
]
...
...
@@ -79,8 +82,24 @@ def update_metadata(commit_sha: str):
pipelines_table
=
pd
.
DataFrame
(
pipelines_table
)
pipelines_dataset
=
Dataset
.
from_pandas
(
pipelines_table
)
hub_pipeline_tags_json
=
hf_hub_download
(
repo_id
=
"huggingface/diffusers-metadata"
,
filename
=
PIPELINE_TAG_JSON
,
repo_type
=
"dataset"
,
)
with
open
(
hub_pipeline_tags_json
)
as
f
:
hub_pipeline_tags_json
=
f
.
read
()
with
tempfile
.
TemporaryDirectory
()
as
tmp_dir
:
pipelines_dataset
.
to_json
(
os
.
path
.
join
(
tmp_dir
,
"pipeline_tags.json"
))
pipelines_dataset
.
to_json
(
os
.
path
.
join
(
tmp_dir
,
PIPELINE_TAG_JSON
))
with
open
(
os
.
path
.
join
(
tmp_dir
,
PIPELINE_TAG_JSON
))
as
f
:
pipeline_tags_json
=
f
.
read
()
hub_pipeline_tags_equal
=
hub_pipeline_tags_json
==
pipeline_tags_json
if
hub_pipeline_tags_equal
:
print
(
"No updates, not pushing the metadata files."
)
return
if
commit_sha
is
not
None
:
commit_message
=
(
...
...
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