Model method to list available models public int $Width = 256; public int $Height = 256; public int $Step = 5; public float $CFG = 7.5; public int $Seed = -1; public float $HiresolutionScale = 2.5; public int $HiresolutionStep = 2; public float $DenoisingStrength = 0.5; public ?int $Timeout = 600; public function __construct( ?string $APIBaseURL = null, ?string $User = null, ?string $Password = null, ?string $NegativePrompt = null, ?string $NegativePrompt = null, ?string $Sampler = null, ?string $Scheduler = null, ?string $Upscaler = null, ?string $Model = null, // NULL = Use default; Use ->Model method to list available models ?int $Width = 256, ?int $Height = 256, ?int $Step = 5, ?float $CFG = 7.5, ?int $Seed = 1, ?float $HiresolutionScale = 2.5, ?int $HiresolutionStep = 2, ?float $DenoisingStrength = 0.5, ){ foreach(get_defined_vars() as $Property => $Value)if(!is_null($Value))$this->$Property = $Value; } } class AUTOMATIC1111{ private const HTTP_ERROR_BY_CODE = [ 401 => ["Message" => "Unauthorized", ], 404 => ["Message" => "Not found", ], 422 => ["Message" => "Unprocessable Content", ], 503 => ["Message" => "Connection refused", ], 504 => ["Message" => "Gateway timeout XXX", ], ]; private const HTTP_METHOD_GET = "GET"; private const HTTP_METHOD_POST = "POST"; private ?\CurlHandle $cURL = null; private array $RequestHeader = [ "Content-Type: application/json", ]; public ?string $APIBaseURL = null; public ?string $User = null; public ?string $Password = null; public ?string $NegativePrompt = null; public ?string $Sampler = null; public ?string $Scheduler = null; public ?string $Upscaler = null; public ?string $Model = null; // NULL = Use default; Use ->Model method to list available models public int $Width = 256; public int $Height = 256; public int $Step = 5; public float $CFG = 7.5; public int $Seed = -1; public float $HiresolutionScale = 2.5; public int $HiresolutionStep = 2; public float $DenoisingStrength = 0.5; public function __construct( ?string $APIBaseURL = null, ?string $User = null, ?string $Password = null, ?string $NegativePrompt = null, ?string $Sampler = null, ?string $Scheduler = null, ?string $Upscaler = null, ?string $Model = null, // NULL = Use default; Use ->Model method to list available models ?int $Width = 256, ?int $Height = 256, ?int $Step = 5, ?float $CFG = 7.5, ?int $Seed = 1, ?float $HiresolutionScale = 2.5, ?int $HiresolutionStep = 2, ?float $DenoisingStrength = 0.5, ){ foreach(get_defined_vars() as $Property => $Value)if(!is_null($Value))$this->$Property = $Value; $this->cURL = curl_init(); } public function __destruct(){ curl_close($this->cURL); } public function QueGeneration( string $Path, string $Prompt, ?int $Width = null, ?int $Height = null, null|array|string $ImageFile = null, ?string $NegativePrompt = null, // Appended to ->NegativePrompt property ?float $CFG = null, ?int $Step = null, ?float $HiresolutionScale = null, ?int $HiresolutionStep = null, ?float $DenoisingStrength = null, ?bool $Tiling = null, ?bool $RestoreFace = null, ?int $Seed = null, ?string $Sampler = null, ?string $Scheduler = null, ?string $Upscaler = null, ?string $Model = null, // NULL = Use default; Use ->Model method to list available models ?int $TimeoutSecond = null, ){ $TaskID = "" . date("Y-m-d-H-i-s") . "-" . UUID(); $Result = $this->ImageGenerationData( $Prompt, $Width, $Height, $ImageFile, $NegativePrompt, $CFG, $Step, $HiresolutionScale, $HiresolutionStep, $DenoisingStrength, $Tiling, $RestoreFace, $Seed, $Sampler, $Scheduler, $Upscaler, $Model, $TimeoutSecond, ); if(!$Result->Error->Code){ $Result->Data->Task = (object)[ "ID" => $TaskID, "Time" => (object)[ "Create" => date("Y-m-d H:i:s"), ], "Status" => "Qued", ]; file_put_contents("{$Path}/Que/{$TaskID}.json", json_encode()); } return $Result; } public function Generate( string $Prompt, ?int $Width = null, ?int $Height = null, null|array|string $ImageFile = null, ?string $NegativePrompt = null, // Appended to ->NegativePrompt property ?float $CFG = null, ?int $Step = null, ?float $HiresolutionScale = null, ?int $HiresolutionStep = null, ?float $DenoisingStrength = null, ?bool $Tiling = null, ?bool $RestoreFace = null, ?int $Seed = null, ?string $Sampler = null, ?string $Scheduler = null, ?string $Upscaler = null, ?string $Model = null, // NULL = Use default; Use ->Model method to list available models ?int $TimeoutSecond = null, ):object{ $ImageGenerationData = $this->ImageGenerationData( $Prompt, $Width, $Height, $ImageFile, $NegativePrompt, $CFG, $Step, $HiresolutionScale, $HiresolutionStep, $DenoisingStrength, $Tiling, $RestoreFace, $Seed, $Sampler, $Scheduler, $Upscaler, $Model, $TimeoutSecond, ); $Result = (object)[ "Error" => $ImageGenerationData->Error, "Data" => (object)[], ]; if(!$Result->Error->Code)$Result = $this->APIRequest( $ImageGenerationData->Data->API->Endpoint, $ImageGenerationData->Data->API->Data, $ImageGenerationData->Data->TimeoutSecond, ); return $Result; } public function QueStatus():object{ return $this->APIRequest("progress"); } public function Option():object{ return $this->APIRequest("options"); } public function Embedding():object{ return $this->APIRequest("embeddings"); } public function PromptStyle():object{ return $this->APIRequest("prompt-styles"); } public function LoRa():object{ return $this->APIRequest("loras"); } public function Upscaler():object{ return $this->APIRequest("upscalers"); } public function Scheduler():object{ return $this->APIRequest("schedulers"); } public function Sampler():object{ return $this->APIRequest("samplers"); } public function Model():object{ return $this->APIRequest("sd-models"); } private function ImageGenerationData( string $Prompt, ?int $Width = null, ?int $Height = null, null|array|string $ImageFile = null, ?string $NegativePrompt = null, // Appended to ->NegativePrompt property ?float $CFG = null, ?int $Step = null, ?float $HiresolutionScale = null, ?int $HiresolutionStep = null, ?float $DenoisingStrength = null, ?bool $Tiling = null, ?bool $RestoreFace = null, ?int $Seed = null, ?string $Sampler = null, ?string $Scheduler = null, ?string $Upscaler = null, ?string $Model = null, // NULL = Use default; Use ->Model method to list available models ?int $TimeoutSecond = null, ):object{ if(is_null($Width))$Width = $this->Width; if(is_null($Height))$Height = $this->Height; if(is_null($ImageFile))$ImageFile = []; if(is_null($CFG))$CFG = $this->CFG; if(is_null($Step))$Step = $this->Step; if(is_null($HiresolutionScale))$HiresolutionScale = $this->HiresolutionScale; if(is_null($HiresolutionStep))$HiresolutionStep = $this->HiresolutionStep; if(is_null($DenoisingStrength))$DenoisingStrength = $this->DenoisingStrength; if(is_null($Tiling))$Tiling = false; if(is_null($RestoreFace))$RestoreFace = false; if(is_null($Seed))$Seed = $this->Seed; if(is_null($Sampler))$Sampler = $this->Sampler; if(is_null($Scheduler))$Scheduler = $this->Scheduler; if(is_null($Upscaler))$Upscaler = $this->Upscaler; if(is_null($Model))$Model = $this->Model; if(is_null($TimeoutSecond))$TimeoutSecond = 300; if(is_string($ImageFile))$ImageFile = [$ImageFile]; if($this->NegativePrompt)$NegativePrompt = $this->NegativePrompt . ($NegativePrompt ? ", {$NegativePrompt}" : null); $Result = (object)[ "Error" => (object)["Code" => 0, "Message" => null, ], "Data" => (object)[], ]; if($Prompt){ $ReferenceImage = []; foreach($ImageFile ?? [] as $ThisImageFile)if(file_exists($ThisImageFile))$ReferenceImage[] = preg_replace("/^data:image\/[a-z]+;base64,/", "", base64_encode(file_get_contents($ThisImageFile))); $OverrideSetting = []; if($Model)$OverrideSetting["sd_model_checkpoint"] = $Model; $Data = [ "prompt" => $Prompt, "init_images" => $ReferenceImage, "negative_prompt" => $NegativePrompt, "width" => $Width, "height" => $Height, "steps" => $Step, "cfg_scale" => $CFG, "seed" => $Seed, "enable_ht" => true, "hr_scale" => $HiresolutionScale, "hr_second_pass_steps" => $HiresolutionStep, "denoising_strength" => $DenoisingStrength, "override_settings" => $OverrideSetting, "tiling" => $Tiling, "restore_faces" => $RestoreFace, "override_settings_restore_afterwards" => true, "send_images" => true, "save_images" => false, ]; if($Sampler)$Data["sampler_name"] = $Sampler; if($Scheduler)$Data["scheduler"] = $Scheduler; if($Upscaler)$Data["hr_upscaler"] = $Upscaler; $APIEndpoint = "" . ($ReferenceImage ? "img" : "txt") . "2img"; $Result->Data = (object)[ "API" => (object)[ "Endpoint" => $APIEndpoint, "Data" => $Data, ], "TimeoutSecond" => $TimeoutSecond ]; } else{ $Result->Error = (object)["Code" => 99999, "Message" => "Prompt missing", ]; } return $Result; } private function APIRequest( string $Endpoint, null|string|array|object $POSTData = null, ?int $TimeoutSecond = null, ):object{ if(is_null($TimeoutSecond))$TimeoutSecond = 600; $Error = (object)["Code" => 0, "Message" => null, ]; $Data = (object)[]; $Method = self::HTTP_METHOD_GET; if($POSTData){ $Method = self::HTTP_METHOD_POST; if( is_array($POSTData) || is_object($POSTData) )$POSTData = json_encode($POSTData); } curl_setopt_array($this->cURL, [ CURLOPT_CUSTOMREQUEST => $Method, CURLOPT_URL => "{$this->APIBaseURL}{$Endpoint}", CURLOPT_HTTPHEADER => $this->RequestHeader, CURLOPT_POSTFIELDS => $POSTData, CURLOPT_HTTPAUTH => $this->User ? \CURLAUTH_BASIC : \CURLAUTH_NONE, CURLOPT_USERPWD => "{$this->User}:{$this->Password}", CURLOPT_TIMEOUT => $TimeoutSecond, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT => 60, ]); set_time_limit($TimeoutSecond); $Response = curl_exec($this->cURL); $HTTPStatusCode = curl_getinfo($this->cURL, \CURLINFO_HTTP_CODE); $cURLErrorCode = curl_errno($this->cURL); $cURLErrorMessage = curl_error($this->cURL); if($cURLErrorCode){ $Error->Code = $cURLErrorCode; $Error->Message = $cURLErrorMessage; } else{ if($HTTPStatusCode == 200){ $Data = json_decode($Response); } else{ $Error = (object)[ "Code" => $HTTPStatusCode, "Message" => self::HTTP_ERROR_BY_CODE[$HTTPStatusCode]["Message"] ?? "API error {$HTTPStatusCode}", ]; } } return (object)[ "Error" => $Error, "Data" => $Data, ]; } } ?>
Warning: Cannot modify header information - headers already sent by (output started at /WWW/default/.library/class/Joy/AUTOMATIC1111.php:1) in /WWW/default/index.php on line 203

Warning: http_response_code(): Cannot set response code - headers already sent (output started at /WWW/default/.library/class/Joy/AUTOMATIC1111.php:1) in /WWW/default/index.php on line 204
{"Title":"Resume for Bogus Boo","Name":"Bogus Boo","Location":"South East Asia","Email":"Boss@Bogus.Boo","Purpose":"Looking for job","Technology":["DNS","Linux","Database","Server maintenance","MySQL","Web server","Mail server","Private cloud implementation","Public cloud deployment","Docker","Virtualization"],"Availability":{"Type":["Full time","Part time","Contractual"],"Joining":"Immediate","Daily":"7 hours","Weekly":"5 days","Exclusion":"Per bank holidays & exclusive festivals"},"Expectation":{"Deployment":["Europe","Open to suggestion"],"Remuneration":"Industry standard","Role":"Consultant"},"Experience":{"HelloWorldYear":"1995","Professional":[{"Position":"CTO","Duration":"3.5 years","Organization":"Start up","Responsibility":["Pioneering product development","IoT","Distributed application","Database architecture","Data communication protocol","Solution architecture","Team formation","Business alignment","Development management","Technology managemeent"]},{"Position":"CTO","Duration":"3 years","Organization":"Start up","Responsibility":["Team formation","Business alignment","Development management","Technology managemeent","Web application","Android & iOS application","Platform management"]},{"Position":"Senior developer","Duration":"3 years","Organization":"Conglomerate","Responsibility":["Web application","PHP","MySQL"]}]},"Quote":["Ask the right question to get the right answer","Passion became profession"]}