Giter Club home page Giter Club logo

Comments (17)

tongyx361 avatar tongyx361 commented on July 28, 2024

Thank you so much for the issue! Let's resolve it together 😀

This error seems a bit unusual because the line of code <title>ImageReward/image_reward.py at main THUDM/ImageReward GitHub</title> does not exist in the sdwebui/image_reward.py file.

Could you please provide the content of your stable-diffusion-webui/scripts/image_reward.py file?

from imagereward.

mageofthesands avatar mageofthesands commented on July 28, 2024

Here it is. I copied it from the file I downloaded from here.

`

<meta name="optimizely-datafile" content="{&quot;groups&quot;: [], &quot;environmentKey&quot;: &quot;production&quot;, &quot;rollouts&quot;: [], &quot;typedAudiences&quot;: [], &quot;projectId&quot;: &quot;16737760170&quot;, &quot;variables&quot;: [], &quot;featureFlags&quot;: [], &quot;experiments&quot;: [], &quot;version&quot;: &quot;4&quot;, &quot;audiences&quot;: [{&quot;conditions&quot;: &quot;[\&quot;or\&quot;, {\&quot;match\&quot;: \&quot;exact\&quot;, \&quot;name\&quot;: \&quot;$opt_dummy_attribute\&quot;, \&quot;type\&quot;: \&quot;custom_attribute\&quot;, \&quot;value\&quot;: \&quot;$opt_dummy_value\&quot;}]&quot;, &quot;id&quot;: &quot;$opt_dummy_audience&quot;, &quot;name&quot;: &quot;Optimizely-Generated Audience for Backwards Compatibility&quot;}], &quot;anonymizeIP&quot;: true, &quot;sdkKey&quot;: &quot;WTc6awnGuYDdG98CYRban&quot;, &quot;attributes&quot;: [{&quot;id&quot;: &quot;16822470375&quot;, &quot;key&quot;: &quot;user_id&quot;}, {&quot;id&quot;: &quot;17143601254&quot;, &quot;key&quot;: &quot;spammy&quot;}, {&quot;id&quot;: &quot;18175660309&quot;, &quot;key&quot;: &quot;organization_plan&quot;}, {&quot;id&quot;: &quot;18813001570&quot;, &quot;key&quot;: &quot;is_logged_in&quot;}, {&quot;id&quot;: &quot;19073851829&quot;, &quot;key&quot;: &quot;geo&quot;}, {&quot;id&quot;: &quot;20175462351&quot;, &quot;key&quot;: &quot;requestedCurrency&quot;}, {&quot;id&quot;: &quot;20785470195&quot;, &quot;key&quot;: &quot;country_code&quot;}, {&quot;id&quot;: &quot;21656311196&quot;, &quot;key&quot;: &quot;opened_downgrade_dialog&quot;}], &quot;botFiltering&quot;: false, &quot;accountId&quot;: &quot;16737760170&quot;, &quot;events&quot;: [{&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;17911811441&quot;, &quot;key&quot;: &quot;hydro_click.dashboard.teacher_toolbox_cta&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18124116703&quot;, &quot;key&quot;: &quot;submit.organizations.complete_sign_up&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18145892387&quot;, &quot;key&quot;: &quot;no_metric.tracked_outside_of_optimizely&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18178755568&quot;, &quot;key&quot;: &quot;click.org_onboarding_checklist.add_repo&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18180553241&quot;, &quot;key&quot;: &quot;submit.repository_imports.create&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18186103728&quot;, &quot;key&quot;: &quot;click.help.learn_more_about_repository_creation&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18188530140&quot;, &quot;key&quot;: &quot;test_event&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18191963644&quot;, &quot;key&quot;: &quot;click.empty_org_repo_cta.transfer_repository&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18195612788&quot;, &quot;key&quot;: &quot;click.empty_org_repo_cta.import_repository&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18210945499&quot;, &quot;key&quot;: &quot;click.org_onboarding_checklist.invite_members&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18211063248&quot;, &quot;key&quot;: &quot;click.empty_org_repo_cta.create_repository&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18215721889&quot;, &quot;key&quot;: &quot;click.org_onboarding_checklist.update_profile&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18224360785&quot;, &quot;key&quot;: &quot;click.org_onboarding_checklist.dismiss&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18234832286&quot;, &quot;key&quot;: &quot;submit.organization_activation.complete&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18252392383&quot;, &quot;key&quot;: &quot;submit.org_repository.create&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18257551537&quot;, &quot;key&quot;: &quot;submit.org_member_invitation.create&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18259522260&quot;, &quot;key&quot;: &quot;submit.organization_profile.update&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18564603625&quot;, &quot;key&quot;: &quot;view.classroom_select_organization&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18568612016&quot;, &quot;key&quot;: &quot;click.classroom_sign_in_click&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18572592540&quot;, &quot;key&quot;: &quot;view.classroom_name&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18574203855&quot;, &quot;key&quot;: &quot;click.classroom_create_organization&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18582053415&quot;, &quot;key&quot;: &quot;click.classroom_select_organization&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18589463420&quot;, &quot;key&quot;: &quot;click.classroom_create_classroom&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18591323364&quot;, &quot;key&quot;: &quot;click.classroom_create_first_classroom&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18591652321&quot;, &quot;key&quot;: &quot;click.classroom_grant_access&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18607131425&quot;, &quot;key&quot;: &quot;view.classroom_creation&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18831680583&quot;, &quot;key&quot;: &quot;upgrade_account_plan&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19064064515&quot;, &quot;key&quot;: &quot;click.signup&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19075373687&quot;, &quot;key&quot;: &quot;click.view_account_billing_page&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19077355841&quot;, &quot;key&quot;: &quot;click.dismiss_signup_prompt&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19079713938&quot;, &quot;key&quot;: &quot;click.contact_sales&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19120963070&quot;, &quot;key&quot;: &quot;click.compare_account_plans&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19151690317&quot;, &quot;key&quot;: &quot;click.upgrade_account_cta&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19424193129&quot;, &quot;key&quot;: &quot;click.open_account_switcher&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19520330825&quot;, &quot;key&quot;: &quot;click.visit_account_profile&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19540970635&quot;, &quot;key&quot;: &quot;click.switch_account_context&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19730198868&quot;, &quot;key&quot;: &quot;submit.homepage_signup&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19820830627&quot;, &quot;key&quot;: &quot;click.homepage_signup&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19988571001&quot;, &quot;key&quot;: &quot;click.create_enterprise_trial&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20036538294&quot;, &quot;key&quot;: &quot;click.create_organization_team&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20040653299&quot;, &quot;key&quot;: &quot;click.input_enterprise_trial_form&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20062030003&quot;, &quot;key&quot;: &quot;click.continue_with_team&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20068947153&quot;, &quot;key&quot;: &quot;click.create_organization_free&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20086636658&quot;, &quot;key&quot;: &quot;click.signup_continue.username&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20091648988&quot;, &quot;key&quot;: &quot;click.signup_continue.create_account&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20103637615&quot;, &quot;key&quot;: &quot;click.signup_continue.email&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20111574253&quot;, &quot;key&quot;: &quot;click.signup_continue.password&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20120044111&quot;, &quot;key&quot;: &quot;view.pricing_page&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20152062109&quot;, &quot;key&quot;: &quot;submit.create_account&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20165800992&quot;, &quot;key&quot;: &quot;submit.upgrade_payment_form&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20171520319&quot;, &quot;key&quot;: &quot;submit.create_organization&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20222645674&quot;, &quot;key&quot;: &quot;click.recommended_plan_in_signup.discuss_your_needs&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20227443657&quot;, &quot;key&quot;: &quot;submit.verify_primary_user_email&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20234607160&quot;, &quot;key&quot;: &quot;click.recommended_plan_in_signup.try_enterprise&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20238175784&quot;, &quot;key&quot;: &quot;click.recommended_plan_in_signup.team&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20239847212&quot;, &quot;key&quot;: &quot;click.recommended_plan_in_signup.continue_free&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20251097193&quot;, &quot;key&quot;: &quot;recommended_plan&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20438619534&quot;, &quot;key&quot;: &quot;click.pricing_calculator.1_member&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20456699683&quot;, &quot;key&quot;: &quot;click.pricing_calculator.15_members&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20467868331&quot;, &quot;key&quot;: &quot;click.pricing_calculator.10_members&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20476267432&quot;, &quot;key&quot;: &quot;click.trial_days_remaining&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20476357660&quot;, &quot;key&quot;: &quot;click.discover_feature&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20479287901&quot;, &quot;key&quot;: &quot;click.pricing_calculator.custom_members&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20481107083&quot;, &quot;key&quot;: &quot;click.recommended_plan_in_signup.apply_teacher_benefits&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20483089392&quot;, &quot;key&quot;: &quot;click.pricing_calculator.5_members&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20484283944&quot;, &quot;key&quot;: &quot;click.onboarding_task&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20484996281&quot;, &quot;key&quot;: &quot;click.recommended_plan_in_signup.apply_student_benefits&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20486713726&quot;, &quot;key&quot;: &quot;click.onboarding_task_breadcrumb&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20490791319&quot;, &quot;key&quot;: &quot;click.upgrade_to_enterprise&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20491786766&quot;, &quot;key&quot;: &quot;click.talk_to_us&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20494144087&quot;, &quot;key&quot;: &quot;click.dismiss_enterprise_trial&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20499722759&quot;, &quot;key&quot;: &quot;completed_all_tasks&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20500710104&quot;, &quot;key&quot;: &quot;completed_onboarding_tasks&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20513160672&quot;, &quot;key&quot;: &quot;click.read_doc&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20516196762&quot;, &quot;key&quot;: &quot;actions_enabled&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20518980986&quot;, &quot;key&quot;: &quot;click.dismiss_trial_banner&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20535446721&quot;, &quot;key&quot;: &quot;click.issue_actions_prompt.dismiss_prompt&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20557002247&quot;, &quot;key&quot;: &quot;click.issue_actions_prompt.setup_workflow&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20595070227&quot;, &quot;key&quot;: &quot;click.pull_request_setup_workflow&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20626600314&quot;, &quot;key&quot;: &quot;click.seats_input&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20642310305&quot;, &quot;key&quot;: &quot;click.decrease_seats_number&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20662990045&quot;, &quot;key&quot;: &quot;click.increase_seats_number&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20679620969&quot;, &quot;key&quot;: &quot;click.public_product_roadmap&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20761240940&quot;, &quot;key&quot;: &quot;click.dismiss_survey_banner&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20767210721&quot;, &quot;key&quot;: &quot;click.take_survey&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20795281201&quot;, &quot;key&quot;: &quot;click.archive_list&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20966790249&quot;, &quot;key&quot;: &quot;contact_sales.submit&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20996500333&quot;, &quot;key&quot;: &quot;contact_sales.existing_customer&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20996890162&quot;, &quot;key&quot;: &quot;contact_sales.blank_message_field&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21000470317&quot;, &quot;key&quot;: &quot;contact_sales.personal_email&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21002790172&quot;, &quot;key&quot;: &quot;contact_sales.blank_phone_field&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21354412592&quot;, &quot;key&quot;: &quot;click.dismiss_create_readme&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21366102546&quot;, &quot;key&quot;: &quot;click.dismiss_zero_user_content&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21370252505&quot;, &quot;key&quot;: &quot;account_did_downgrade&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21370840408&quot;, &quot;key&quot;: &quot;click.cta_create_readme&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21375451068&quot;, &quot;key&quot;: &quot;click.cta_create_new_repository&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21385390948&quot;, &quot;key&quot;: &quot;click.zero_user_content&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21467712175&quot;, &quot;key&quot;: &quot;click.downgrade_keep&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21484112202&quot;, &quot;key&quot;: &quot;click.downgrade&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21495292213&quot;, &quot;key&quot;: &quot;click.downgrade_survey_exit&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21508241468&quot;, &quot;key&quot;: &quot;click.downgrade_survey_submit&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21512030356&quot;, &quot;key&quot;: &quot;click.downgrade_support&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21539090022&quot;, &quot;key&quot;: &quot;click.downgrade_exit&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21543640644&quot;, &quot;key&quot;: &quot;click_fetch_upstream&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21646510300&quot;, &quot;key&quot;: &quot;click.move_your_work&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21656151116&quot;, &quot;key&quot;: &quot;click.add_branch_protection_rule&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21663860599&quot;, &quot;key&quot;: &quot;click.downgrade_dialog_open&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21687860483&quot;, &quot;key&quot;: &quot;click.learn_about_protected_branches&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21689050333&quot;, &quot;key&quot;: &quot;click.dismiss_protect_this_branch&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21864370109&quot;, &quot;key&quot;: &quot;click.sign_in&quot;}], &quot;revision&quot;: &quot;1372&quot;}" />
<script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/wp-runtime-9a794f867114.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_stacktrace-parser_dist_stack-trace-parser_esm_js-node_modules_github_bro-a4c183-ae93d3fba59c.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_failbot_failbot_ts-e38c93eab86e.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/environment-de3997b81651.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_selector-observer_dist_index_esm_js-2646a2c533e3.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_relative-time-element_dist_index_js-99e288659d4f.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_fzy_js_index_js-node_modules_github_markdown-toolbar-element_dist_index_js-e3de700a4c9d.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_auto-complete-element-5b3870-ff38694180c6.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_text-ex-3415a8-7ecc10fb88d0.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_remote-inp-8873b7-5771678648e0.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_view-components_app_components_primer_primer_js-node_modules_gith-3af896-d8cf3e5f5813.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/github-elements-6f05fe60d18a.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/element-registry-90a0fb4e73fa.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_lit-html_lit-html_js-9d9fe1859ce5.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_github_alive-client_dist-bf5aa2-424aa982deef.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_turbo_dist_turbo_es2017-esm_js-ba0e4d5b3207.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_color-convert_index_js-node_modules_github_jtml_lib_index_js-40bf234a19dc.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_scroll-anchoring_dist_scro-52dc4b-e1e33bfc0b7e.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_paste-markdown_dist_index_esm_js-node_modules_github_quote-select-743f1d-1b20d530fbf0.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_updatable-content_ts-dadb69f79923.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_keyboard-shortcuts-helper_ts-app_assets_modules_github_be-f5afdb-3f05df4c282b.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_sticky-scroll-into-view_ts-0af96d15a250.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_ajax-error_ts-app_assets_modules_github_behaviors_include-2e2258-7effad8d88d4.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_commenting_edit_ts-app_assets_modules_github_behaviors_ht-83c235-c97eacdef68a.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_blob-anchor_ts-app_assets_modules_github_filter-sort_ts-app_assets_-e5f169-c54621d9e188.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/behaviors-a934992bd4b4.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_catalyst_lib_index_js-623425af41e1.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/notifications-global-4dc6f295cc92.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_optimizely_optimizely-sdk_dist_optimizely_browser_es_min_js-node_modules-089adc-2328ba323205.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/optimizely-1c55a525615e.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_virtualized-list_es_index_js-node_modules_github_template-parts_lib_index_js-c3e624db1d89.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_decorators_js-node_modules_github_remote-form_-e3de2b-93bbe15e6e78.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_filter--b2311f-15fe0f17a114.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_ref-selector_ts-8f8b76ecd8d3.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/repositories-0355d3fe50ee.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_clipboard-copy-element_dist_index_esm_js-node_modules_scroll-anch-c93c97-d63d35dd5d0b.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_diffs_blob-lines_ts-app_assets_modules_github_diffs_linkable-line-n-f96c66-97aade341120.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/diffs-e4bf217e85f5.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/code-menu-da1cefc25b0a.js"></script> <title>ImageReward/image_reward.py at main · THUDM/ImageReward · GitHub</title>

<meta name="hovercard-subject-tag" content="repository:622147274" data-turbo-transient>
<meta name="google-site-verification" content="c1kuD-K2HIVF635lypcsWPoD4kilo5-jA_wBFyT4uMY">
<meta name="user-login" content="">



<meta name="viewport" content="width=device-width">

  <meta name="description" content="ImageReward: Learning and Evaluating Human Preferences for Text-to-image Generation - ImageReward/image_reward.py at main · THUDM/ImageReward">
  <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub">
<link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub">
<meta property="fb:app_id" content="1401488693436528">
<meta name="apple-itunes-app" content="app-id=1477376905" />
  <meta name="twitter:image:src" content="https://opengraph.githubassets.com/2b2876e997eab53b78a172a6c70a75078a35af6fd8e45baf27b5e92e5a8a5d6d/THUDM/ImageReward" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ImageReward/image_reward.py at main · THUDM/ImageReward" /><meta name="twitter:description" content="ImageReward: Learning and Evaluating Human Preferences for Text-to-image Generation - ImageReward/image_reward.py at main · THUDM/ImageReward" />
  <meta property="og:image" content="https://opengraph.githubassets.com/2b2876e997eab53b78a172a6c70a75078a35af6fd8e45baf27b5e92e5a8a5d6d/THUDM/ImageReward" /><meta property="og:image:alt" content="ImageReward: Learning and Evaluating Human Preferences for Text-to-image Generation - ImageReward/image_reward.py at main · THUDM/ImageReward" /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="ImageReward/image_reward.py at main · THUDM/ImageReward" /><meta property="og:url" content="https://github.com/THUDM/ImageReward" /><meta property="og:description" content="ImageReward: Learning and Evaluating Human Preferences for Text-to-image Generation - ImageReward/image_reward.py at main · THUDM/ImageReward" />
  



    <meta name="hostname" content="github.com">



    <meta name="expected-hostname" content="github.com">

<meta name="enabled-features" content="TURBO_EXPERIMENT_RISKY,IMAGE_METRIC_TRACKING,GEOJSON_AZURE_MAPS">
    <meta data-hydrostats="publish">

<link rel="canonical" href="https://github.com/THUDM/ImageReward/blob/main/sdwebui/image_reward.py" data-turbo-transient>
<div class="position-relative js-header-wrapper ">
  <a href="#start-of-content" class="px-2 py-4 color-bg-accent-emphasis color-fg-on-emphasis show-on-focus js-skip-to-content">Skip to content</a>
  <span data-view-component="true" class="progress-pjax-loader Progress position-fixed width-full">
<span style="width: 0%;" data-view-component="true" class="Progress-item progress-pjax-loader-bar left-0 top-0 color-bg-accent-emphasis"></span>
        <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_github_memoize_dist_esm_in-687f35-d131f0b6de8e.js"></script>
<script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/sessions-2638decb9ee5.js"></script> Toggle navigation
    <div class="flex-1">
      <a href="/signup?ref_cta=Sign+up&amp;ref_loc=header+logged+out&amp;ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fblob%2Fshow&amp;source=header-repo"
        class="d-inline-block d-lg-none flex-order-1 f5 no-underline border color-border-default rounded-2 px-2 py-1 color-fg-inherit"
        data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;originating_url&quot;:&quot;https://github.com/THUDM/ImageReward/blob/main/sdwebui/image_reward.py&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="f3347295860b4fa44cd75f279060b99361641505ecbaed414445f3e13ba167ed"
      >
        Sign&nbsp;up
      </a>
    </div>

  <div class="flex-1 flex-order-2 text-right">
      <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target Button--link Button--medium Button d-lg-none color-fg-inherit p-1">    <span class="Button-content">
  <span class="Button-label"><div class="HeaderMenu-toggle-bar rounded my-1"></div>
        <div class="HeaderMenu-toggle-bar rounded my-1"></div>
        <div class="HeaderMenu-toggle-bar rounded my-1"></div></span>
</span>
<div class="HeaderMenu--logged-out p-responsive height-fit position-lg-relative d-lg-flex flex-column flex-auto pt-7 pb-4 top-0">
  <div class="header-menu-wrapper d-flex flex-column flex-self-end flex-lg-row flex-justify-between flex-auto p-3 p-lg-0 rounded rounded-lg-0 mt-3 mt-lg-0">
      <nav class="mt-0 px-3 px-lg-0 mb-3 mb-lg-0" aria-label="Global">
        <ul class="d-lg-flex list-style-none">
            <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item">
  <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false">
    Product
    <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1">
<path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path>
</div>
<div id="js-flash-container" data-turbo-replace>
  <div>{{ message }}</div>

</div>
<include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment>
  <div class="d-flex flex-wrap flex-justify-end mb-3  px-3 px-md-4 px-lg-5" style="gap: 1rem;">

    <div class="flex-auto min-width-0 width-fit mr-3">
<span class="author flex-self-stretch" itemprop="author">
  <a class="url fn" rel="author" data-hovercard-type="organization" data-hovercard-url="/orgs/THUDM/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/THUDM">
    THUDM


/

ImageReward

<span></span><span class="Label Label--secondary v-align-middle mr-1">Public</span>
    </div>

    <div id="repository-details-container" data-turbo-replace>
        <ul class="pagehead-actions flex-shrink-0 d-none d-md-inline" style="padding: 2px 0;">
  • Notifications
  • Fork 23
  •     </div>
      </div>
    
        <div id="responsive-meta-container" data-turbo-replace>
    
          <nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5">
    

    Permalink

    main
    Switch branches/tags
    <input-demux data-action="tab-container-change:input-demux#storeInput tab-container-changed:input-demux#updateInput">
      <tab-container class="d-flex flex-column js-branches-tags-tabs" style="min-height: 0;">
        <div class="SelectMenu-filter">
          <input data-target="input-demux.source"
                 id="context-commitish-filter-field"
                 class="SelectMenu-input form-control"
                 aria-owns="ref-list-branches"
                 data-controls-ref-menu-id="ref-list-branches"
                 autofocus
                 autocomplete="off"
                 aria-label="Filter branches/tags"
                 placeholder="Filter branches/tags"
                 type="text"
          >
        </div>
    
        <div class="SelectMenu-tabs" role="tablist" data-target="input-demux.control" >
          <button class="SelectMenu-tab" type="button" role="tab" aria-selected="true">Branches</button>
          <button class="SelectMenu-tab" type="button" role="tab">Tags</button>
        </div>
    
        <div role="tabpanel" id="ref-list-branches" data-filter-placeholder="Filter branches/tags" tabindex="" class="d-flex flex-column flex-auto overflow-auto">
          <ref-selector
            type="branch"
            data-targets="input-demux.sinks"
            data-action="
              input-entered:ref-selector#inputEntered
              tab-selected:ref-selector#tabSelected
              focus-list:ref-selector#focusFirstListMember
            "
            query-endpoint="/THUDM/ImageReward/refs"
            
            cache-key="v0:1681308785.0"
            current-committish="bWFpbg=="
            default-branch="bWFpbg=="
            name-with-owner="VEhVRE0vSW1hZ2VSZXdhcmQ="
            prefetch-on-mouseover
          >
    
            <template data-target="ref-selector.fetchFailedTemplate">
              <div class="SelectMenu-message" data-index="{{ index }}">Could not load branches</div>
            </template>
    
              <template data-target="ref-selector.noMatchTemplate">
    <div class="SelectMenu-message">Nothing to show</div>
    
            <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list " data-turbo-frame="repo-content-turbo-frame">
              <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading">
                <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate">
    
    {{ refName }} default
              <footer class="SelectMenu-footer"><a href="/THUDM/ImageReward/branches">View all branches</a></footer>
          </ref-selector>
    
        </div>
    
        <div role="tabpanel" id="tags-menu" data-filter-placeholder="Find a tag" tabindex="" hidden class="d-flex flex-column flex-auto overflow-auto">
          <ref-selector
            type="tag"
            data-action="
              input-entered:ref-selector#inputEntered
              tab-selected:ref-selector#tabSelected
              focus-list:ref-selector#focusFirstListMember
            "
            data-targets="input-demux.sinks"
            query-endpoint="/THUDM/ImageReward/refs"
            cache-key="v0:1681308785.0"
            current-committish="bWFpbg=="
            default-branch="bWFpbg=="
            name-with-owner="VEhVRE0vSW1hZ2VSZXdhcmQ="
          >
    
            <template data-target="ref-selector.fetchFailedTemplate">
              <div class="SelectMenu-message" data-index="{{ index }}">Could not load tags</div>
            </template>
    
            <template data-target="ref-selector.noMatchTemplate">
              <div class="SelectMenu-message" data-index="{{ index }}">Nothing to show</div>
            </template>
    
    {{ refName }} default
            <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list" data-turbo-frame="repo-content-turbo-frame">
              <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading">
                <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate">
    
    View all tags

    Name already in use

          <div data-view-component="true">      A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
    
    </div>
      <footer class="Overlay-footer Overlay-footer--alignEnd">
            <button data-close-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn">    Cancel
    
    Create

    ImageReward/sdwebui/image_reward.py /
    Jump to

    Go to file
    • Go to file T
    • Go to line L
    • Go to definition R
    •         Copy path
      



    •         <span class="d-flex flex-items-baseline">
                <span class="flex-auto">Copy permalink</span>
              </span>
      


    <div id="spoof-warning" class="mt-0 pb-3" hidden aria-hidden>
    
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert float-left mt-1">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
    
      <div class="overflow-hidden">This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.</div>
    
    <include-fragment src="/THUDM/ImageReward/spoofed_commit_check/ed5c202ec4ffa368ddc2546c08fa272ce86bca8e" data-test-selector="spoofed-commit-check"></include-fragment>
    
    <div class="Box d-flex flex-column flex-shrink-0 mb-3">
    
    @tongyx361
    tongyx361
              <span class="markdown-title">
                <a data-pjax="true" title="Smoothen installation in SD Web UI script." class="Link--secondary" href="/THUDM/ImageReward/commit/5b3c50b88698b4e69d0f52ba2812ce6cfdbb9db3">Smoothen installation in SD Web UI script.</a>
              </span>
          </div>
    
    
          <span class="ml-2">
            <include-fragment accept="text/fragment+html" src="/THUDM/ImageReward/commit/5b3c50b88698b4e69d0f52ba2812ce6cfdbb9db3/rollup?direction=e" class="d-inline"></include-fragment>
          </span>
        </div>
        <div class="ml-3 d-flex flex-shrink-0 flex-items-center flex-justify-end color-fg-muted no-wrap">
          <span class="d-none d-md-inline">
            <span>Latest commit</span>
            <a class="text-small text-mono Link--secondary" href="/THUDM/ImageReward/commit/5b3c50b88698b4e69d0f52ba2812ce6cfdbb9db3" data-pjax>5b3c50b</a>
            <span itemprop="dateModified"><relative-time datetime="2023-05-23T05:29:55Z" class="no-wrap">May 23, 2023</relative-time></span>
          </span>
    
          <a data-pjax href="/THUDM/ImageReward/commits/main/sdwebui/image_reward.py" class="ml-3 no-wrap Link--primary no-underline">
            <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-history">
    <path d="m.427 1.927 1.215 1.215a8.002 8.002 0 1 1-1.6 5.685.75.75 0 1 1 1.493-.154 6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"></path>
    
    History
    1
        contributor
      </summary>
      <details-dialog
        class="Box Box--overlay d-flex flex-column anim-fade-in fast"
        aria-label="Users who have contributed to this file"
        src="/THUDM/ImageReward/contributors-list/main/sdwebui/image_reward.py" preload>
        <div class="Box-header">
          <button class="Box-btn-octicon btn-octicon float-right" type="button" aria-label="Close dialog" data-close-dialog>
            <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x">
    <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path>
    

    Users who have contributed to this file

    <div data-target="readme-toc.content" class="Box mt-3 position-relative">
    
      121 lines (105 sloc)
      <span class="file-info-divider"></span>
    4.14 KB
    
    <div class="BtnGroup">
        <a data-permalink-href="/THUDM/ImageReward/raw/ed5c202ec4ffa368ddc2546c08fa272ce86bca8e/sdwebui/image_reward.py" href="/THUDM/ImageReward/raw/main/sdwebui/image_reward.py" id="raw-url" group_item="true" data-view-component="true" class="js-permalink-replaceable-link Button--secondary Button--small Button">    <span class="Button-content">
      <span class="Button-label">Raw</span>
    </span>
    
    Blame
    <div class="d-flex">
    
    Edit this file
    E
            <a data-platforms="windows,mac" aria-label="Open this file in GitHub Desktop" href="https://desktop.github.com" data-view-component="true" class="SelectMenu-item no-wrap js-remove-unless-platform width-full text-normal color-fg-default f5">
              Open in GitHub Desktop
    

























          <button class="btn-octicon btn-octicon-danger disabled tooltipped tooltipped-nw" disabled
            aria-label="You must be signed in to make or propose changes" type="button">
            <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-trash">
    <path d="M11 1.75V3h2.25a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1 0-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75ZM4.496 6.675l.66 6.6a.25.25 0 0 0 .249.225h5.19a.25.25 0 0 0 .249-.225l.66-6.6a.75.75 0 0 1 1.492.149l-.66 6.6A1.748 1.748 0 0 1 10.595 15h-5.19a1.75 1.75 0 0 1-1.741-1.575l-.66-6.6a.75.75 0 1 1 1.492-.15ZM6.5 1.75V3h3V1.75a.25.25 0 0 0-.25-.25h-2.5a.25.25 0 0 0-.25.25Z"></path>
    
    <div class="d-flex hide-lg hide-xl flex-order-2 flex-grow-0">
      <details class="dropdown details-reset details-overlay d-inline-block">
        <summary
          class="js-blob-dropdown-click btn-octicon"
          aria-haspopup="true"
          aria-label="Possible actions"
          
          data-dropdown-tracking="{&quot;type&quot;:&quot;blob_edit_dropdown.more_options_click&quot;,&quot;context&quot;:{&quot;repository_id&quot;:622147274,&quot;actor_id&quot;:null,&quot;github_dev_enabled&quot;:false,&quot;edit_enabled&quot;:false,&quot;small_screen&quot;:true}}"
        >
          <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal">
    <path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path>
    
        <ul class="dropdown-menu dropdown-menu-sw" style="width: 175px">
            <li>
                <a class="dropdown-item tooltipped tooltipped-nw js-remove-unless-platform"
                   data-platforms="windows,mac"
                   href="https://desktop.github.com">
                  Open with Desktop
                </a>
            </li>
          <li>
            <a class="dropdown-item" href="/THUDM/ImageReward/raw/main/sdwebui/image_reward.py">
              View raw
            </a>
          </li>
            <li>
              <remote-clipboard-copy class="dropdown-item" data-src="/THUDM/ImageReward/raw/main/sdwebui/image_reward.py" data-action="click:remote-clipboard-copy#remoteCopy">
    


    Copy raw contents

    Copy raw contents







    Copy raw contents




    Copy raw contents







  • View blame

  •     </ul>
      </details>
    </div>
    
    <div itemprop="text" class="Box-body p-0 blob-wrapper data type-python  gist-border-0">
    
    This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
    import os
    import subprocess
    import sys
    from pathlib import Path
    import gradio as gr
    import modules.images as images
    import modules.scripts as scripts
    import torch
    from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE
    from modules import sd_samplers, shared
    from modules.processing import (
    Processed,
    StableDiffusionProcessing,
    create_infotext,
    process_images,
    )
    from modules.shared import cmd_opts, opts, state
    try:
    import ImageReward as reward
    except ModuleNotFoundError as error:
    print('"image-reward" package has not been properly installed. Installing...')
    if subprocess.check_call(["pip", "install", "image-reward"]) == 0:
    print(f'"image-reward" package is successfully installed!')
    import ImageReward as reward
    else:
    print('"image-reward" package installation failed!')
    print(
    "Please open an issue with full error message at https://github.com/THUDM/ImageReward/issues"
    )
    def unload_image_reward_model():
    del shared.image_reward_model
    class Script(scripts.Script):
    def title(self):
    return "ImageReward - generate human preference scores"
    def show(self, is_txt2img):
    return True
    def ui(self, is_txt2img):
    with gr.Blocks():
    with gr.Row():
    gr.Markdown(
    value="**Tip**: It will take a little time to **load** the ImageReward model before **the first generation**."
    )
    with gr.Row():
    with gr.Column():
    filter_out_low_scores = gr.Checkbox(
    value=False, label="Filter out images with low scores"
    )
    with gr.Column():
    lower_score_limit = gr.Textbox(value=0, label="Lower score limit")
    with gr.Row():
    gr.Markdown(
    value="ImageReward model takes about **1,600 MB** of memory."
    )
    with gr.Row():
    unload_button = gr.Button(value="Unload Model From Memory")
    unload_button.click(unload_image_reward_model)
    return [filter_out_low_scores, lower_score_limit]
    def run(self, p, filter_out_low_scores, lower_score_limit):
    try:
    shared.image_reward_model # if loaded, do nothing
    except AttributeError:
    # load the model
    if sys.platform == "win32":
    download_root = HUGGINGFACE_HUB_CACHE
    else:
    download_root = None
    print(f"Loading ImageReward model from {download_root}...")
    shared.image_reward_model = reward.load(
    "ImageReward-v1.0", download_root=download_root
    ) # using shared to make the model object global among modules
    # preprocess parameters
    if lower_score_limit != "":
    lower_score_limit = float(lower_score_limit)
    # generate images
    proc = process_images(p)
    # score
    gens = proc.images
    with torch.no_grad():
    for img in gens:
    score = shared.image_reward_model.score(p.prompt, img)
    img.info["score"] = score
    if img.info.get("parameters") is None:
    img.info["parameters"] = f"ImageReward Score: {score:.4f}"
    else:
    img.info["parameters"] += f"\n ImageReward Score: {score:.4f}"
    # filter out images with scores lower than the lower limit
    if filter_out_low_scores:
    imgs = list(filter(lambda x: x.info["score"] > lower_score_limit, gens))
    else:
    imgs = gens
    # append score to info
    infotexts = [img.info["parameters"] for img in imgs]
    # sort to score
    img_info_list = list(zip(imgs, infotexts))
    img_info_list.sort(key=lambda x: x[0].info["score"], reverse=True)
    imgs, infotexts = list(zip(*img_info_list))
    # return Processed object
    return Processed(
    p=p,
    images_list=imgs,
    info=proc.info,
    seed=proc.seed,
    infotexts=infotexts,
    index_of_first_image=proc.index_of_first_image,
    )
      <ul class="BlobToolbar-dropdown dropdown-menu dropdown-menu-se ml-2 mt-2"
      style="width:185px"
      >
        <li>
          <clipboard-copy role="menuitem" class="dropdown-item" id="js-copy-lines" style="cursor:pointer;" aria-label="Copy lines">
            Copy lines
          </clipboard-copy>
        </li>
        <li>
          <clipboard-copy role="menuitem" class="dropdown-item" id="js-copy-permalink" style="cursor:pointer;" aria-label="Copy permalink">
            Copy permalink
          </clipboard-copy>
        </li>
        <li><a class="dropdown-item js-update-url-with-hash" id="js-view-git-blame" role="menuitem" href="/THUDM/ImageReward/blame/ed5c202ec4ffa368ddc2546c08fa272ce86bca8e/sdwebui/image_reward.py">View git blame</a></li>
          <li><a class="dropdown-item" id="js-new-issue" role="menuitem" href="/THUDM/ImageReward/issues/new">Reference in new issue</a></li>
      </ul>
    </details-menu>
    
    </div>
    
    </div>
    
    Go
    <div class="Popover anim-scale-in js-tagsearch-popover"
     hidden
     data-tagsearch-url="/THUDM/ImageReward/find-definition"
     data-tagsearch-ref="main"
     data-tagsearch-code-nav-context="BLOB_VIEW">
    
    </main>
    
          <footer class="footer width-full container-xl p-responsive" role="contentinfo">
    

    Footer

    © 2023 GitHub, Inc.
    <nav aria-label='Footer' class="col-12 col-lg-8">
      <h3 class='sr-only' id='sr-footer-heading'>Footer navigation</h3>
      <ul class="list-style-none d-flex flex-wrap col-12 flex-justify-center flex-lg-justify-between mb-2 mb-lg-0" aria-labelledby='sr-footer-heading'>
          <li class="mr-3 mr-lg-0"><a href="https://docs.github.com/site-policy/github-terms/github-terms-of-service" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to terms&quot;,&quot;label&quot;:&quot;text:terms&quot;}">Terms</a></li>
          <li class="mr-3 mr-lg-0"><a href="https://docs.github.com/site-policy/privacy-policies/github-privacy-statement" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to privacy&quot;,&quot;label&quot;:&quot;text:privacy&quot;}">Privacy</a></li>
          <li class="mr-3 mr-lg-0"><a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to security&quot;,&quot;label&quot;:&quot;text:security&quot;}" href="https://github.com/security">Security</a></li>
          <li class="mr-3 mr-lg-0"><a href="https://www.githubstatus.com/" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to status&quot;,&quot;label&quot;:&quot;text:status&quot;}">Status</a></li>
          <li class="mr-3 mr-lg-0"><a data-ga-click="Footer, go to help, text:Docs" href="https://docs.github.com">Docs</a></li>
          <li class="mr-3 mr-lg-0"><a href="https://support.github.com?tags=dotcom-footer" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to contact&quot;,&quot;label&quot;:&quot;text:contact&quot;}">Contact GitHub</a></li>
          <li class="mr-3 mr-lg-0"><a href="https://github.com/pricing" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to Pricing&quot;,&quot;label&quot;:&quot;text:Pricing&quot;}">Pricing</a></li>
        <li class="mr-3 mr-lg-0"><a href="https://docs.github.com" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to api&quot;,&quot;label&quot;:&quot;text:api&quot;}">API</a></li>
        <li class="mr-3 mr-lg-0"><a href="https://services.github.com" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to training&quot;,&quot;label&quot;:&quot;text:training&quot;}">Training</a></li>
          <li class="mr-3 mr-lg-0"><a href="https://github.blog" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to blog&quot;,&quot;label&quot;:&quot;text:blog&quot;}">Blog</a></li>
          <li><a data-ga-click="Footer, go to about, text:about" href="https://github.com/about">About</a></li>
      </ul>
    </nav>
    
    You can’t perform that action at this time.
    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
    <div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0">
    
    <template id="snippet-clipboard-copy-button">
    
    </div>
    
    <div id="js-global-screen-reader-notice" class="sr-only" aria-live="polite" ></div>
    

    `

    from imagereward.

    tongyx361 avatar tongyx361 commented on July 28, 2024

    It looks like you have downloaded the HTML of a web page instead of our script code file. This is actually the wrong way to do it.

    The contents of image_reward.py should be the following Python code:

    import os
    import subprocess
    import sys
    from pathlib import Path
    import gradio as gr
    import modules.images as images
    import modules.scripts as scripts
    import torch
    from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE
    from modules import sd_samplers, shared
    from modules.processing import (
    Processed,
    StableDiffusionProcessing,
    create_infotext,
    process_images,
    )
    from modules.shared import cmd_opts, opts, state
    try:
    import ImageReward as reward
    except ModuleNotFoundError as error:
    print('"image-reward" package has not been properly installed. Installing...')
    if subprocess.check_call(["pip", "install", "image-reward"]) == 0:
    print(f'"image-reward" package is successfully installed!')
    import ImageReward as reward
    else:
    print('"image-reward" package installation failed!')
    print(
    "Please open an issue with full error message at https://github.com/THUDM/ImageReward/issues"
    )
    def unload_image_reward_model():
    del shared.image_reward_model
    class Script(scripts.Script):
    def title(self):
    return "ImageReward - generate human preference scores"
    def show(self, is_txt2img):
    return True
    def ui(self, is_txt2img):
    with gr.Blocks():
    with gr.Row():
    gr.Markdown(
    value="**Tip**: It will take a little time to **load** the ImageReward model before **the first generation**."
    )
    with gr.Row():
    with gr.Column():
    filter_out_low_scores = gr.Checkbox(
    value=False, label="Filter out images with low scores"
    )
    with gr.Column():
    lower_score_limit = gr.Textbox(value=0, label="Lower score limit")
    with gr.Row():
    gr.Markdown(
    value="ImageReward model takes about **1,600 MB** of memory."
    )
    with gr.Row():
    unload_button = gr.Button(value="Unload Model From Memory")
    unload_button.click(unload_image_reward_model)
    return [filter_out_low_scores, lower_score_limit]
    def run(self, p, filter_out_low_scores, lower_score_limit):
    try:
    shared.image_reward_model # if loaded, do nothing
    except AttributeError:
    # load the model
    if sys.platform == "win32":
    download_root = HUGGINGFACE_HUB_CACHE
    else:
    download_root = None
    print(f"Loading ImageReward model from {download_root}...")
    shared.image_reward_model = reward.load(
    "ImageReward-v1.0", download_root=download_root
    ) # using shared to make the model object global among modules
    # preprocess parameters
    if lower_score_limit != "":
    lower_score_limit = float(lower_score_limit)
    # generate images
    proc = process_images(p)
    # score
    gens = proc.images
    with torch.no_grad():
    for img in gens:
    score = shared.image_reward_model.score(p.prompt, img)
    img.info["score"] = score
    if img.info.get("parameters") is None:
    img.info["parameters"] = f"ImageReward Score: {score:.4f}"
    else:
    img.info["parameters"] += f"\n ImageReward Score: {score:.4f}"
    # filter out images with scores lower than the lower limit
    if filter_out_low_scores:
    imgs = list(filter(lambda x: x.info["score"] > lower_score_limit, gens))
    else:
    imgs = gens
    # append score to info
    infotexts = [img.info["parameters"] for img in imgs]
    # sort to score
    img_info_list = list(zip(imgs, infotexts))
    img_info_list.sort(key=lambda x: x[0].info["score"], reverse=True)
    imgs, infotexts = list(zip(*img_info_list))
    # return Processed object
    return Processed(
    p=p,
    images_list=imgs,
    info=proc.info,
    seed=proc.seed,
    infotexts=infotexts,
    index_of_first_image=proc.index_of_first_image,
    )

    instead of the HTML code starting with

    <meta name="optimizely-datafile" content="{&quot;groups&quot;: [], ...
    

    from imagereward.

    mageofthesands avatar mageofthesands commented on July 28, 2024

    When I right click that script code file, and "save link as..." I get a file that starts off with

    <!DOCTYPE html>
    <html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" data-a11y-animated-images="system">
      <head>
        <meta charset="utf-8">
      <link rel="dns-prefetch" href="https://github.githubassets.com">
      <link rel="dns-prefetch" href="https://avatars.githubusercontent.com">
      <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com">
      <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">
      <link rel="preconnect" href="https://github.githubassets.com" crossorigin>
      <link rel="preconnect" href="https://avatars.githubusercontent.com">
    

    from imagereward.

    mageofthesands avatar mageofthesands commented on July 28, 2024

    I edited with .py with the information listed. I still get get an error that ImageReward is not installed.

    from imagereward.

    tongyx361 avatar tongyx361 commented on July 28, 2024

    When I right click that script code file, and "save link as..." I get a file that starts off with

    <!DOCTYPE html>
    <html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" data-a11y-animated-images="system">
      <head>
        <meta charset="utf-8">
      <link rel="dns-prefetch" href="https://github.githubassets.com">
      <link rel="dns-prefetch" href="https://avatars.githubusercontent.com">
      <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com">
      <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">
      <link rel="preconnect" href="https://github.githubassets.com" crossorigin>
      <link rel="preconnect" href="https://avatars.githubusercontent.com">
    

    I edited with .py with the information listed. I still get get an error that ImageReward is not installed.

    The link we provided for the script file points to its GitHub page, not the raw content. So "save as link" will save the HTML code of the GitHub page, not the actual Python code of the script.

    If the image_reward.py code you have is correct Python code yet still triggered an error, that would be strange.

    Could you provide the full error message?

    from imagereward.

    mageofthesands avatar mageofthesands commented on July 28, 2024

    imagerewardfail1

    from imagereward.

    mageofthesands avatar mageofthesands commented on July 28, 2024

    imagereward6323851

    Starting from launching.

    from imagereward.

    tongyx361 avatar tongyx361 commented on July 28, 2024

    imagereward6323851

    Starting from launching.

    File "F:\AI\Diffusion\stable-diffusion-webui-directml\scripts\image_reward.py", line 1
         import os 
    IndentationError: unexpected indent 
    

    The error above means the indentation syntax in your image_reward.py is wrong, which might be caused by some copying mistake.

    You might try directly downloading the image_reward.py with the button shown below, and move it into the scripts/ directory.
    image

    from imagereward.

    mageofthesands avatar mageofthesands commented on July 28, 2024

    Steps followed. On launch, the software said that ImageReward was installed incorrectly, and it would now do so correctly. New issue. tqdm.exe is not found. I attempted to correct myself, but tqdm is already installed. It looks like Image Reward installed tqdm, but couldn't run it?
    imagereward64231042

    from imagereward.

    tongyx361 avatar tongyx361 commented on July 28, 2024

    Steps followed. On launch, the software said that ImageReward was installed incorrectly, and it would now do so correctly. New issue. tqdm.exe is not found. I attempted to correct myself, but tqdm is already installed. It looks like Image Reward installed tqdm, but couldn't run it? imagereward64231042

    The key error message here is

    WARNING: Failed to write executable - trying to use .deleteme logic
    ERROR: Could not install packages due to an OSError: [WinError 2] The system cannot find the file specified: 'C:\\Python311\\\\Scripts\\\\tqdm.exe' -> 'C. \\\Python311\\Scripts\\\tqdm.exe.deleteme'
    

    pip may have failed to write to the executable due to lack of permissions, etc., causing the "image-reward" pip package to fail to be installed.

    "tqdm" is one of the dependencies of "image-reward". You are on the right track: you could try installing the "tqdm" package manually.
    But you may have missed a special design of SD Web UI: webui-user.bat uses the automatically created venv environment, while you should have tried to install "tqdm" in the machine's Python when you fixed it, and the two environments are different, so the error was not fixed.

    You can refer to this issue to try to install "tqdm" manually in venv, and install "image-reward" again.

    from imagereward.

    mageofthesands avatar mageofthesands commented on July 28, 2024

    It's now loading. Script is working. Although, I guess I can't run it at the same time as the StylePile Script. On the image browser though, it's not letting me use the Generate ImageReward Scores for all images button.
    I hope this has assisted in development of your software.
    imagereward652023836
    imagereward652023852
    imagereward652023854

    from imagereward.

    tongyx361 avatar tongyx361 commented on July 28, 2024

    It's now loading. Script is working. Although, I guess I can't run it at the same time as the StylePile Script. On the image browser though, it's not letting me use the Generate ImageReward Scores for all images button. I hope this has assisted in development of your software. imagereward652023836 imagereward652023852 imagereward652023854

    Glad you got the error resolved! If you encounter any related errors/new bugs in the future, please feel free to reply under this issue/open a new one, so that we can work together to make this project better!👍

    Regarding the issue with running other scripts at the same time, I'm sorry, but the SD Web UI hasn't supported running multiple scripts at the same time so far.

    Also, from your reply and image, it looks like "the StylePile script" is integrated with ImageReward, and I'm glad that other developers are willing to use our work!

    But I failed to retrieve ImageReward in the StylePile code repository. could you please provide a full UI screenshot of your last image? We'd like to get more insight into the application of our work.

    from imagereward.

    mageofthesands avatar mageofthesands commented on July 28, 2024

    It doesn't look like there is any integration between the two. This is what a StylePile looks like. A bunch of variables, either set or pulled from random. I should be able to generate Image Reward scores from the image browser, right? That button is unusable.
    imagereward6623822

    from imagereward.

    tongyx361 avatar tongyx361 commented on July 28, 2024

    It doesn't look like there is any integration between the two. This is what a StylePile looks like. A bunch of variables, either set or pulled from random. I should be able to generate Image Reward scores from the image browser, right? That button is unusable. imagereward6623822

    The UI is quite different from a usual SD Web UI's interface. Are you using the extension edition of StockPile? I wonder how I can get the same UI as yours.

    It seems that you want to score these images with ImageReward? We're sorry that we could have been only able to ensure generating ImageReward Score with the ImageReward script. Perhaps you could use "Send to txt2img" or "Send to img2img" to use the script in the "txt2img" or "img2img" tab to generate ImageReward scores for the images.

    from imagereward.

    mageofthesands avatar mageofthesands commented on July 28, 2024

    Ah, yes. I am using the "Catppuccin Theme". https://github.com/catppuccin/stable-diffusion-webui I wanted a dark mode. I couldn't see the tool tips otherwise. Also the Image Browser extension. https://github.com/AlUlkesh/stable-diffusion-webui-images-browser I forget what isn't default.

    Are you saying that you didn't place that button there? It was there before I was able to get the script working.

    imagereward6623948

    from imagereward.

    tongyx361 avatar tongyx361 commented on July 28, 2024

    Thank you so much! We'll delve into them soon. Please stay tuned.

    from imagereward.

    Related Issues (20)

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. 📊📈🎉

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google ❤️ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.