{"payload":{"allShortcutsEnabled":false,"fileTree":{"src/stable-diffusion-streamlit/pages/model":{"items":[{"name":"__init__.py","path":"src/stable-diffusion-streamlit/pages/model/__init__.py","contentType":"file"},{"name":"copy_pb.py","path":"src/stable-diffusion-streamlit/pages/model/copy_pb.py","contentType":"file"},{"name":"download_onnx.py","path":"src/stable-diffusion-streamlit/pages/model/download_onnx.py","contentType":"file"},{"name":"inference.py","path":"src/stable-diffusion-streamlit/pages/model/inference.py","contentType":"file"},{"name":"prepare.py","path":"src/stable-diffusion-streamlit/pages/model/prepare.py","contentType":"file"},{"name":"quantization.py","path":"src/stable-diffusion-streamlit/pages/model/quantization.py","contentType":"file"},{"name":"thread.py","path":"src/stable-diffusion-streamlit/pages/model/thread.py","contentType":"file"}],"totalCount":7},"src/stable-diffusion-streamlit/pages":{"items":[{"name":"model","path":"src/stable-diffusion-streamlit/pages/model","contentType":"directory"},{"name":"文字转图片.py","path":"src/stable-diffusion-streamlit/pages/文字转图片.py","contentType":"file"},{"name":"画廊.py","path":"src/stable-diffusion-streamlit/pages/画廊.py","contentType":"file"}],"totalCount":3},"src/stable-diffusion-streamlit":{"items":[{"name":"pages","path":"src/stable-diffusion-streamlit/pages","contentType":"directory"},{"name":"entrypoint.sh","path":"src/stable-diffusion-streamlit/entrypoint.sh","contentType":"file"},{"name":"requirements.txt","path":"src/stable-diffusion-streamlit/requirements.txt","contentType":"file"},{"name":"主页.py","path":"src/stable-diffusion-streamlit/主页.py","contentType":"file"}],"totalCount":4},"src":{"items":[{"name":"stable-diffusion-streamlit","path":"src/stable-diffusion-streamlit","contentType":"directory"}],"totalCount":1},"":{"items":[{"name":".github","path":".github","contentType":"directory"},{"name":"doc","path":"doc","contentType":"directory"},{"name":"docker","path":"docker","contentType":"directory"},{"name":"src","path":"src","contentType":"directory"},{"name":".dockerignore","path":".dockerignore","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"README_CN.md","path":"README_CN.md","contentType":"file"}],"totalCount":9}},"fileTreeProcessingTime":17.999537999999998,"foldersToFetch":[],"reducedMotionEnabled":null,"repo":{"id":546836711,"defaultBranch":"main","name":"stable-diffusion-streamlit","ownerLogin":"LowinLi","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2022-10-06T18:19:36.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/33021512?v=4","public":true,"private":false,"isOrgOwned":false},"refInfo":{"name":"main","listCacheKey":"v0:1665123374.24305","canEdit":false,"refType":"branch","currentOid":"f0f89f1ca432cfe89a80c774829893661aa1608f"},"path":"src/stable-diffusion-streamlit/pages/model/quantization.py","currentUser":null,"blob":{"rawLines":["import os","from onnxruntime.quantization import quantize_dynamic, QuantType","","","def quant():"," for root, dirs, filenames in os.walk(\"./onnx\"):"," if \"model.onnx\" in filenames:"," if \"weights.pb\" in filenames:"," external_data = True"," else:"," external_data = False"," quantize_dynamic("," model_input=os.path.join(root, \"model.onnx\"),"," model_output=os.path.join(root, \"model.onnx\"), # 量化后直接覆盖原onnx文件"," per_channel=True,"," reduce_range=True,"," weight_type=QuantType.QUInt8,"," optimize_model=True,"," use_external_data_format=external_data,"," )"," print(\"Quantized model saved at: \", os.path.join(root, \"model.onnx\"))"," if \"weights.pb\" in filenames:"," os.remove(os.path.join(root, \"weights.pb\"))"," print(\"Removed weights.pb\")","","","if __name__ == \"__main__\":"," quant()"],"stylingDirectives":[[{"start":0,"end":6,"cssClass":"pl-k"},{"start":7,"end":9,"cssClass":"pl-s1"}],[{"start":0,"end":4,"cssClass":"pl-k"},{"start":5,"end":16,"cssClass":"pl-s1"},{"start":17,"end":29,"cssClass":"pl-s1"},{"start":30,"end":36,"cssClass":"pl-k"},{"start":37,"end":53,"cssClass":"pl-s1"},{"start":55,"end":64,"cssClass":"pl-v"}],[],[],[{"start":0,"end":3,"cssClass":"pl-k"},{"start":4,"end":9,"cssClass":"pl-en"}],[{"start":4,"end":7,"cssClass":"pl-k"},{"start":8,"end":12,"cssClass":"pl-s1"},{"start":14,"end":18,"cssClass":"pl-s1"},{"start":20,"end":29,"cssClass":"pl-s1"},{"start":30,"end":32,"cssClass":"pl-c1"},{"start":33,"end":35,"cssClass":"pl-s1"},{"start":36,"end":40,"cssClass":"pl-en"},{"start":41,"end":49,"cssClass":"pl-s"}],[{"start":8,"end":10,"cssClass":"pl-k"},{"start":11,"end":23,"cssClass":"pl-s"},{"start":24,"end":26,"cssClass":"pl-c1"},{"start":27,"end":36,"cssClass":"pl-s1"}],[{"start":12,"end":14,"cssClass":"pl-k"},{"start":15,"end":27,"cssClass":"pl-s"},{"start":28,"end":30,"cssClass":"pl-c1"},{"start":31,"end":40,"cssClass":"pl-s1"}],[{"start":16,"end":29,"cssClass":"pl-s1"},{"start":30,"end":31,"cssClass":"pl-c1"},{"start":32,"end":36,"cssClass":"pl-c1"}],[{"start":12,"end":16,"cssClass":"pl-k"}],[{"start":16,"end":29,"cssClass":"pl-s1"},{"start":30,"end":31,"cssClass":"pl-c1"},{"start":32,"end":37,"cssClass":"pl-c1"}],[{"start":12,"end":28,"cssClass":"pl-en"}],[{"start":16,"end":27,"cssClass":"pl-s1"},{"start":27,"end":28,"cssClass":"pl-c1"},{"start":28,"end":30,"cssClass":"pl-s1"},{"start":31,"end":35,"cssClass":"pl-s1"},{"start":36,"end":40,"cssClass":"pl-en"},{"start":41,"end":45,"cssClass":"pl-s1"},{"start":47,"end":59,"cssClass":"pl-s"}],[{"start":16,"end":28,"cssClass":"pl-s1"},{"start":28,"end":29,"cssClass":"pl-c1"},{"start":29,"end":31,"cssClass":"pl-s1"},{"start":32,"end":36,"cssClass":"pl-s1"},{"start":37,"end":41,"cssClass":"pl-en"},{"start":42,"end":46,"cssClass":"pl-s1"},{"start":48,"end":60,"cssClass":"pl-s"},{"start":64,"end":80,"cssClass":"pl-c"}],[{"start":16,"end":27,"cssClass":"pl-s1"},{"start":27,"end":28,"cssClass":"pl-c1"},{"start":28,"end":32,"cssClass":"pl-c1"}],[{"start":16,"end":28,"cssClass":"pl-s1"},{"start":28,"end":29,"cssClass":"pl-c1"},{"start":29,"end":33,"cssClass":"pl-c1"}],[{"start":16,"end":27,"cssClass":"pl-s1"},{"start":27,"end":28,"cssClass":"pl-c1"},{"start":28,"end":37,"cssClass":"pl-v"},{"start":38,"end":44,"cssClass":"pl-v"}],[{"start":16,"end":30,"cssClass":"pl-s1"},{"start":30,"end":31,"cssClass":"pl-c1"},{"start":31,"end":35,"cssClass":"pl-c1"}],[{"start":16,"end":40,"cssClass":"pl-s1"},{"start":40,"end":41,"cssClass":"pl-c1"},{"start":41,"end":54,"cssClass":"pl-s1"}],[],[{"start":12,"end":17,"cssClass":"pl-en"},{"start":18,"end":46,"cssClass":"pl-s"},{"start":48,"end":50,"cssClass":"pl-s1"},{"start":51,"end":55,"cssClass":"pl-s1"},{"start":56,"end":60,"cssClass":"pl-en"},{"start":61,"end":65,"cssClass":"pl-s1"},{"start":67,"end":79,"cssClass":"pl-s"}],[{"start":12,"end":14,"cssClass":"pl-k"},{"start":15,"end":27,"cssClass":"pl-s"},{"start":28,"end":30,"cssClass":"pl-c1"},{"start":31,"end":40,"cssClass":"pl-s1"}],[{"start":16,"end":18,"cssClass":"pl-s1"},{"start":19,"end":25,"cssClass":"pl-en"},{"start":26,"end":28,"cssClass":"pl-s1"},{"start":29,"end":33,"cssClass":"pl-s1"},{"start":34,"end":38,"cssClass":"pl-en"},{"start":39,"end":43,"cssClass":"pl-s1"},{"start":45,"end":57,"cssClass":"pl-s"}],[{"start":16,"end":21,"cssClass":"pl-en"},{"start":22,"end":42,"cssClass":"pl-s"}],[],[],[{"start":0,"end":2,"cssClass":"pl-k"},{"start":3,"end":11,"cssClass":"pl-s1"},{"start":12,"end":14,"cssClass":"pl-c1"},{"start":15,"end":25,"cssClass":"pl-s"}],[{"start":4,"end":9,"cssClass":"pl-en"}]],"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/LowinLi/stable-diffusion-streamlit/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null,"repoAlertsPath":"/LowinLi/stable-diffusion-streamlit/security/dependabot","repoSecurityAndAnalysisPath":"/LowinLi/stable-diffusion-streamlit/settings/security_analysis","repoOwnerIsOrg":false,"currentUserCanAdminRepo":false},"displayName":"quantization.py","displayUrl":"https://github.com/LowinLi/stable-diffusion-streamlit/blob/main/src/stable-diffusion-streamlit/pages/model/quantization.py?raw=true","headerInfo":{"blobSize":"999 Bytes","deleteInfo":{"deletePath":null,"deleteTooltip":"You must be signed in to make or propose changes"},"editInfo":{"editTooltip":"You must be signed in to make or propose changes"},"ghDesktopPath":"https://desktop.github.com","gitLfsPath":null,"onBranch":true,"shortPath":"76a75f9","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2FLowinLi%2Fstable-diffusion-streamlit%2Fblob%2Fmain%2Fsrc%2Fstable-diffusion-streamlit%2Fpages%2Fmodel%2Fquantization.py","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"28","truncatedSloc":"24"},"mode":"file"},"image":false,"isCodeownersFile":null,"isValidLegacyIssueTemplate":false,"issueTemplateHelpUrl":"https://docs.github.com/articles/about-issue-and-pull-request-templates","issueTemplate":null,"discussionTemplate":null,"language":"Python","large":false,"loggedIn":false,"newDiscussionPath":"/LowinLi/stable-diffusion-streamlit/discussions/new","newIssuePath":"/LowinLi/stable-diffusion-streamlit/issues/new","planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/LowinLi/stable-diffusion-streamlit/blob/main/src/stable-diffusion-streamlit/pages/model/quantization.py","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","dismissStackNoticePath":"/settings/dismiss-notice/publish_stack_from_file","releasePath":"/LowinLi/stable-diffusion-streamlit/releases/new?marketplace=true","showPublishActionBanner":false,"showPublishStackBanner":false},"renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"repoOwner":"LowinLi","repoName":"stable-diffusion-streamlit","showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","showDependabotConfigurationBanner":false,"actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timedOut":false,"notAnalyzed":false,"symbols":[{"name":"quant","kind":"function","identStart":81,"identEnd":86,"extentStart":77,"extentEnd":957,"fullyQualifiedName":"quant","identUtf16":{"start":{"lineNumber":4,"utf16Col":4},"end":{"lineNumber":4,"utf16Col":9}},"extentUtf16":{"start":{"lineNumber":4,"utf16Col":0},"end":{"lineNumber":23,"utf16Col":43}}}]}},"copilotUserAccess":null,"csrf_tokens":{"/LowinLi/stable-diffusion-streamlit/branches":{"post":"eJjsNRVp8sZQ7zWnchUTmZXYgQPIgC-7asdU5zc71FiIpXRFsTu3r8XNV1yExX9Q4A-dFz6Hl7iOi0tGdOxL8A"}}},"title":"stable-diffusion-streamlit/src/stable-diffusion-streamlit/pages/model/quantization.py at main · LowinLi/stable-diffusion-streamlit","locale":"en"}