1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[439],{10241:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>O});var s=l(6029),a=l(50433),n=l(74536),r=l(87462),i=l(37948),o=l(84335),d=l(63887),c=l(13692),m=l(56266),u=l(26500),p=l(69943),h=l(99690),g=l(92388),x=l(75318),f=l(24565),j=l(12660),b=l(56233),_=l(12638),y=l(74738),v=l(18090),E=l(50016),k=l(26312),w=l(34417),C=l(1751),P=l(58943),M=l(89948),z=l(37514),A=l(55729),S=l(87041);let R=(0,A.memo)(e=>{let{files:t,onUpload:l}=e,a=(0,A.useMemo)(()=>t.some(e=>"uploading"===e.status),[t]);return(0,s.jsx)(o.$,{onClick:l,loading:a,size:"lg",fullWidth:!0,children:a?"Uploading...":"Start Upload"})}),N=(0,A.memo)(e=>{let{fileWithStatus:t,onRemove:l}=e,n=(0,A.useCallback)(()=>{l(t.file.name)},[t.file.name,l]);return(0,s.jsx)(d.f,{span:3,md:2,children:(0,s.jsxs)(a.a,{sx:{position:"relative"},children:[(0,s.jsx)(c._,{height:100,src:URL.createObjectURL(t.file),alt:"preview",sx:{filter:"idle"!==t.status?"brightness(60%)":"none"}}),(0,s.jsxs)(a.a,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:["uploaded"===t.status&&(0,s.jsx)(k.A,{}),"uploading"===t.status&&(0,s.jsx)(m.a,{size:"md",color:"green"})]}),"idle"===t.status&&(0,s.jsx)(u.M,{variant:"filled",color:"red",sx:{position:"absolute",top:5,right:5},onClick:n,children:(0,s.jsx)(E.raE,{})})]})})}),Y=(0,A.memo)(e=>{let{files:t,onRemove:l}=e;return(0,s.jsx)(p.x,{my:30,children:t.map(e=>(0,s.jsx)(N,{fileWithStatus:e,onRemove:l},e.file.name))})}),D=e=>{let{training_type:t,onComplete:l}=e,{files:n,form:c,handleDrop:m,uploadFiles:u,removeFile:k,handleSubmit:N,isAllUploaded:D,isLoading:U}=((e,t)=>{let[l,s]=(0,A.useState)([]),{mutate:a,isLoading:n}=(0,C.fEh)(),{mutateAsync:r}=(0,C.fAw)(),{refetch:i}=(0,C.x$b)(),[o,d]=(0,A.useState)([]),c=()=>Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,6),m=(0,y.m)({initialValues:{activation_word:c(),project_name:c(),object_type:P.PK.Man,train_batch_size:6,unet_lr:6e-4,num_epochs:400}}),u=e=>{s(t=>t.filter(t=>t.file.name!==e))},p=(0,A.useCallback)(async()=>{if(l.length<M.Xg)return void(0,v.Ds)({title:"Not enough photos",message:"Please upload at least ".concat(M.Xg," photos for good results."),color:"red"});let e=l.filter(e=>"idle"===e.status);for(let t=0;t<e.length;t+=20){let l=e.slice(t,t+20);s(e=>{let t=new Map(e.map(e=>[e.file.name,e]));return l.forEach(e=>{let l=t.get(e.file.name);l&&t.set(e.file.name,{...l,status:"uploading"})}),Array.from(t.values())});try{let e=await Promise.all(l.map(e=>r({data:{image:e.file}})));s(e=>{let t=new Map(e.map(e=>[e.file.name,e]));return l.forEach((e,l)=>{let s=t.get(e.file.name);s&&t.set(e.file.name,{...s,status:"uploaded"})}),Array.from(t.values())}),d(t=>[...t,...e])}catch(e){(0,z.A)(e),l.forEach(e=>u(e.file.name))}}},[l,r,u]);return{files:l,form:m,handleDrop:(0,A.useCallback)(e=>{if(l.length+e.length>M.BE)return void(0,v.Ds)({title:"Too many photos added",message:"Maximum ".concat(M.BE," photos allowed. You can add ").concat(M.BE-l.length," more."),color:"red"});let t=e.map(e=>({file:e,status:"idle"}));s(e=>[...e,...t])},[l.length]),uploadFiles:p,removeFile:(0,A.useCallback)(u,[]),handleSubmit:(0,A.useCallback)(()=>{if(o.length<M.Xg)return void(0,v.Ds)({title:"Not enough photos",message:"Please upload at least ".concat(M.Xg," photos for good results."),color:"red"});a({data:{...m.values,images:o.map(e=>e.id),training_type:e}},{onSuccess:e=>{(0,v.Ds)({title:"Lora training created",message:"Lora training ".concat(e.project_name," created successfully"),color:"green"}),s([]),d([]),m.reset(),i(),t()},onError:e=>{(0,z.A)(e),s([]),d([]),m.reset()}})},[m.values,o,e]),isAllUploaded:(0,A.useMemo)(()=>l.every(e=>"uploaded"===e.status),[l]),isLoading:n}})(t,l),{data:L}=(0,w.P)();return(0,s.jsxs)(S.A,{children:[(0,s.jsx)(r.h,{align:"center",mt:"lg",order:3,children:"Upload Your Pictures"}),(0,s.jsxs)(a.a,{sx:e=>({padding:e.spacing.xl,[e.fn.smallerThan("md")]:{padding:e.spacing.md}}),children:[0===n.length&&(0,s.jsx)(b.mR,{onDrop:m,accept:_.Oq,maxSize:3*0x4000000000000,children:(0,s.jsxs)(h.Y,{position:"center",spacing:"lg",style:{minHeight:(0,g.D)(120),pointerEvents:"none"},py:30,children:[(0,s.jsx)(b.mR.Accept,{children:(0,s.jsx)(E.JMY,{style:{transform:"scale(1.5)"}})}),(0,s.jsx)(b.mR.Reject,{children:(0,s.jsx)(E.raE,{style:{transform:"scale(1.5)"}})}),(0,s.jsxs)(a.a,{children:[(0,s.jsx)(h.Y,{position:"center",my:30,children:(0,s.jsx)(E.JMY,{style:{transform:"scale(2.5)"}})}),(0,s.jsx)(i.E,{size:"xl",inline:!0,children:"Drag images here or click to select files"}),(0,s.jsx)(i.E,{size:"sm",color:"dimmed",inline:!0,mt:7,children:"File should not exceed 5mb"})]})]})}),n.length>0&&(0,s.jsx)(Y,{files:n,onRemove:k}),(null==L?void 0:L.is_staff)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.Q,{label:"Batch Size",...c.getInputProps("train_batch_size")}),(0,s.jsx)(f.k,{label:"Learning Rate",...c.getInputProps("unet_lr")}),(0,s.jsx)(x.Q,{label:"Number of Epochs",...c.getInputProps("num_epochs")})]}),D&&(0,s.jsx)(a.a,{component:"form",onSubmit:N,my:10,children:(0,s.jsxs)(p.x,{gutter:30,align:"flex-start",children:[(0,s.jsx)(d.f,{span:12,md:6,children:(0,s.jsx)(f.k,{label:"Model Name",required:!0,description:"You can find this model by name in your studio later",...c.getInputProps("project_name")}
1)}),(0,s.jsx)(d.f,{span:12,md:6,children:(0,s.jsx)(j.l6,{label:"Gender",data:Object.values(P.PK).map(e=>({label:e,value:e})),required:!0,description:"Select your gender",...c.getInputProps("object_type")})})]})}),(0,s.jsx)(h.Y,{position:"center",mt:"xl",children:D?(0,s.jsx)(o.$,{onClick:N,loading:U,size:"lg",children:"Create Model"}):(0,s.jsx)(R,{files:n,onUpload:u})})]})]})};var U=l(78138),L=l(81278);let O=()=>{let e=(0,L.useRouter)();return(0,s.jsx)(a.a,{sx:e=>({minHeight:"800px",padding:"60px 20px 50px 20px",[e.fn.smallerThan("md")]:{padding:"40px 10px"}}),children:(0,s.jsxs)(n.Z,{children:[(0,s.jsx)(r.h,{order:2,align:"center",mb:"md",children:"Create Your Own Model"}),(0,s.jsx)(i.E,{align:"center",color:"dimmed",mb:"xl",children:"Upload your images and get a personalized model based on your pictures."}),(0,s.jsx)(D,{training_type:P.QC.General,onComplete:()=>{e.push(U.J.aieasypic.trainLorasAll)}})]})})}},83339:(e,t,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/train/loras/create",function(){return l(10241)}])}},e=>{e.O(0,[182,4003,636,6593,8792],()=>e(e.s=83339)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.