Skip to content

Commit

Permalink
Merge pull request AUTOMATIC1111#9 from xiehust/dev
Browse files Browse the repository at this point in the history
fix s3 path error
  • Loading branch information
xieyongliang committed Apr 13, 2023
2 parents 06824a5 + b6105fd commit 0b680c8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions localizations/zh_CN.json
Expand Up @@ -852,5 +852,6 @@
"Input S3 path of images":"输入图片的S3路径",
"Submit":"确定",
"columns width":"每行图片列数",
"Show current user's images only":"只显示当前用户图片集",
"--------": "--------"
}
11 changes: 8 additions & 3 deletions modules/ui.py
Expand Up @@ -735,7 +735,10 @@ def list_objects(bucket,prefix=''):
objects = response['Contents'] if response.get('Contents') else []
return [obj['Key'] for obj in objects]

def image_viewer(path,cols_width,request:gr.Request):
def image_viewer(path,cols_width,current_only,request:gr.Request):
if current_only:
username = get_webui_username(request)
path = path+'/'+username
dirs = path.replace('s3://','').split('/')
prefix = '/'.join(dirs[1:])
bucket = dirs[0]
Expand All @@ -755,14 +758,16 @@ def image_viewer(path,cols_width,request:gr.Request):
with gr.Blocks(analytics_enabled=False) as imagesviewer_interface:
with gr.Row():
with gr.Column(scale=3):
images_s3_path = gr.Textbox(label="Input S3 path of images",value = get_default_sagemaker_bucket()+'/output-images')
images_s3_path = gr.Textbox(label="Input S3 path of images",value = get_default_sagemaker_bucket()+'/stable-diffusion-webui/generated')
with gr.Column(scale=1):
show_user_only = gr.Checkbox(label="Show current user's images only", value=True)
with gr.Column(scale=1):
cols_width = gr.Slider(minimum=4, maximum=20, step=1, label="columns width", value=8)
with gr.Column(scale=1):
images_s3_path_btn = gr.Button(value="Submit",variant='primary')
with gr.Row():
result = gr.HTML("<div style='height:300px;border:1px solid #e9ebed;border-radius:10px;'></div>")
images_s3_path_btn.click(fn=image_viewer, inputs=[images_s3_path,cols_width], outputs=[result])
images_s3_path_btn.click(fn=image_viewer, inputs=[images_s3_path,cols_width,show_user_only], outputs=[result])


## end
Expand Down
5 changes: 3 additions & 2 deletions webui.py
Expand Up @@ -242,6 +242,7 @@ def check_space_s3_download(s3_client,bucket_name,s3_folder,local_folder,file,si
# s3_client = boto3.client('s3')
src = s3_folder + '/' + file
dist = os.path.join(local_folder, file)
os.makedirs(os.path.dirname(dist), exist_ok=True)
# Get disk usage statistics
disk_usage = psutil.disk_usage('/tmp')
freespace = disk_usage.free/(1024**3)
Expand Down Expand Up @@ -508,11 +509,11 @@ def register_sd_models(sd_models_dir):
for file in get_models(sd_models_dir, ['*.ckpt', '*.safetensors']):
hash = modules.sd_models.model_hash(file)
item = {}
item['model_name'] = os.path.basename(file)
item['model_name'] = file.replace("/tmp/models/Stable-diffusion/",'')
item['hash'] = hash
item['filename'] = file
item['config'] = '/opt/ml/code/stable-diffusion-webui/repositories/stable-diffusion/configs/stable-diffusion/v1-inference.yaml'
item['title'] = '{0} [{1}]'.format(os.path.basename(file), hash)
item['title'] = '{0} [{1}]'.format(file.replace("/tmp/models/Stable-diffusion/",''), hash)
item['endpoint_name'] = endpoint_name
items.append(item)
inputs = {
Expand Down

0 comments on commit 0b680c8

Please sign in to comment.