<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Stefano on Medium]]></title>
        <description><![CDATA[Stories by Stefano on Medium]]></description>
        <link>https://medium.com/@stefanomartin?source=rss-3ae71f5ee20b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ukRYneeqxnDqj7IecqITnA.jpeg</url>
            <title>Stories by Stefano on Medium</title>
            <link>https://medium.com/@stefanomartin?source=rss-3ae71f5ee20b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 09:15:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stefanomartin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Wappsto — 3. Ruby VS Rails]]></title>
            <link>https://medium.com/@stefanomartin/wappsto-3-ruby-vs-rails-321702de22e1?source=rss-3ae71f5ee20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/321702de22e1</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Stefano]]></dc:creator>
            <pubDate>Wed, 05 Jul 2023 06:50:42 GMT</pubDate>
            <atom:updated>2023-07-05T06:50:42.690Z</atom:updated>
            <content:encoded><![CDATA[<h3>Wappsto — 3. Ruby VS Rails</h3><p>One of the interesting fact of Wappsto API is that, at the contrary of many Ruby backends, it does not use Ruby on Rails. In fact I built a backend in pure Ruby without using the magic of the favorited suite of the Ruby community.</p><p>Of course the question that everybody would like to ask is: “why we took this decision?” It is an interesting question that I asked also to myself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rFynhICWI5gr5DLy5CdcaQ.png" /><figcaption>The beauty of Ruby and a little train on its Rails</figcaption></figure><p>I was not the original creator of the API and at the begin of my job at Seluxit I found myself looking with curiosity on the Ruby code that managed the backend. With everybody else busy in creating frontend or hardware code, I felt the need to help by managing this tiny server.</p><p>After two years of hard work the tiny API became a Monolith: difficult to manage and to handle it. It was at that moment that we decided to switch from a macro to a micro-service structure (it was around 2019).</p><p>As you see from my previous blog, the transformation from a macro to a micro structure was a harsh and dramatic procedure that involved a drastic transformation of all the backend. And it was at the moment that I ask to the team: why do we not switch to Ruby on Rails?</p><p>There were many pro by using Rails:</p><ul><li>It was a reliable, well tested, full of feature framework used by thousands of developers for different reasons</li><li>It introduced only few year before a version to use it as an API (in 2016 with version 5.0)</li><li>It had a great integration with server and emails</li><li>It could be managed easily from different developers</li></ul><p>However we decide to continue on our way and to use Ruby without Rails.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zePF7p1okQ19TPbpSeyijA.png" /><figcaption>Structured and fantastic Rails</figcaption></figure><p><strong>Structure of the cloud</strong></p><p>The first main reason came from the micro-service structure that we want to provide. For us it was very important to avoid repetition of the code and try to solve issues on multiple micro-services at once. As I described in the previous blog post, this was accomplished by adding to each micro-services a micro-core sub repository with inside the shared code.</p><p>Having a similar under structure in Rails was going against its own logic and it was giving a framework layer inside another framework layer. A micro-core together with Rails would have added a too high complexity.</p><p><strong>Refactoring of the code</strong></p><p>Rewriting all the code from macro to micro had been a successful challenge, but I was able to keep a lot of logic from the original commits. Rewriting in Rails would have been meant a complete deletion of all the code: a task that I do not recommend to anybody.</p><p><strong>Database flexibility</strong></p><p>Ruby on Rails is amazing for SQL and PostgreSQL database, however the main core of our cloud was <a href="https://www.couchbase.com/">Couchbase</a>: a very fast and reliable document NoSQL database.</p><p>The main <a href="https://github.com/couchbase/couchbase-ruby-client">Couchbase ruby gem</a> had a period of “not maintained” long several years and it was great to see come alive again in the recent years. However the<a href="https://github.com/couchbase/couchbase-ruby-model"> Couchbase rails gem</a> already at the time was 5 years not maintained and even today the project seems to be archived.</p><p>Leaving the document flexibility of Couchbase for SQL was a big no-no and this was a big point against the usage of Rails.</p><p>Adding the fact that in some contexts, for example to manage historical data, we wanted to use an additional PostgreSQL database. Having two databases at the same time added a complexity that the formal Ruby on Rails seemed to not provide very easily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4yk37kAayBQUCVMQvHrYhw.png" /><figcaption>Micro-services interacting with the database in the center</figcaption></figure><p><strong>Agnostic backend</strong></p><p>We also wished to make our backend to be only an API. We did not care to provide HTML pages from the server, but at the contrary we wanted to make an API that mostly returns only structured JSON documents.</p><p>This permitted to access our API with React for frontend handling, but also from R for data analysis or with node.js to create background web applications.</p><p>The API version of Rails was still relatively new and using Rails for the frontend was not our purpose.</p><p><strong>Performance</strong></p><p>By not using Rails I was giving the possibility to handle library and performance trick with more freedom. This includes the following choices:</p><ul><li>Create a cache for the database to avoid repetitive requests</li><li>Reduce the number of requests to the database by doing bulks requests</li><li>Freedom to choose fast libraries (for example for validation of the data or Thin instead of Puma)</li><li>Possibility to use Fibers instead of Thread to handle I/O conditions</li></ul><p>The final result was an impressive API that can handle multiple requests at once.</p><p><strong>What I took from Rails?</strong></p><p>Rails is an amazing tool and by analyzing it and by creating some little project I cherry pick some nice features.</p><p>In particular I took inspiration from the Rack middlewares and the Model View Controller logic. Having those gave a sense of structure that otherwise would not be easy to replicate.</p><p>The final choice was not easy since Ruby on Rails is a great framework that it is a great fit for the majorities of the companies. However I think that for Wappsto API we did the correct choice: the final API was quick, scalable, easy to maintain, and with the ability to add features and improvements very fast.</p><p>I am satisfied of the decision we took at the time and it helped me to understand strengths and weaknesses of Ruby with and without Rails.</p><p>I hope that you liked my new post blog, please do not be shy and share it with friends and colleague if you find it interesting.</p><p>All the images were created by me with Stable diffusion.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=321702de22e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wappsto — 2. From macro to micro]]></title>
            <link>https://medium.com/@stefanomartin/wappsto-2-from-macro-to-micro-abef8a0d9757?source=rss-3ae71f5ee20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/abef8a0d9757</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[couchbase]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Stefano]]></dc:creator>
            <pubDate>Fri, 30 Jun 2023 11:26:51 GMT</pubDate>
            <atom:updated>2023-06-30T11:26:51.203Z</atom:updated>
            <content:encoded><![CDATA[<h3>Wappsto — 2. From macro to micro</h3><p>One of the most interesting challenge that I had at Seluxit was how to convert our Cloud from a macro-service (a monolith) to a micro-service structure.</p><p>At the time Wappsto API was a a huge big application that was handling few operations mainly focusing on storing a network structure and authenticate the users. However with the time the needs for more feature changed and it required the addition of services like notifications, applications and file handling, email support, streaming operation and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wnFiX5GJ2LYJEzHts_e7Pw.png" /><figcaption>This picture is a metaphor: a developer (the men on horse) escaping the Monolith (the castle)</figcaption></figure><p>This created an huge applications that it was required more and more time in testing, maintenance, and releasing. A small quirk in the notification logic could create issues on streaming. A bad loop in the session authentication risked to create a delay in the handling of the updating of the state of a network.</p><p>Also the scalability was an issue because more clients was requiring a higher number of macro structure that need to continue to communicate with each other to achieve a good streaming handling.</p><p>For these reasons I need to rewrote from zero all the applications to provide a micro-service structure that could be scalable, stable, easy to maintain, and with the possibility to add new features without brake the system.</p><p><strong>Structure and scalability</strong></p><p>The first challenge was giving a structure to the new logic. A possible choice was to make every micro-service very tiny: a small micro-service to store the data, another for authenticate the user, one to receive the data, one to handle the validation of the data, and so on. Then for every request, every micro-service communicate and wait for each other and then give out the desired output. However this approach was going to create performance issues for any sucked single micro-service.</p><p>I preferred to use a different approach where each service was able to handle its own field of pertinence. For example we have micro-network to handle all the operations concerning a network, micro-historical for storing and retrieving historical data, micro-application to create and handle publishing of files and applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KcTDcXGZPFHXD6LOgOSq3w.png" /><figcaption>Structure and balance</figcaption></figure><p>As a rule we agree that each micro-service had to be independent as much as possibile. Requiring features stored in another micro-services should be a rare occasion. For example:</p><ul><li>Creating an user (micro-user service) during the registration phase (under micro-session service)</li><li>Sending an email (micro-email service) if the user is lacking points (micro-wallet service)</li></ul><p>In general the communication between micro-services is passive. For example, assume that an user wants to update the color of a light. To achieve this he communicates with the micro-network. The API updates the “light” document and then sends out in an event pool this information. In the meanwhile the user receives that the light has been turned on successfully. Afterward the micro-historical draws from the pool of the events the updated state and it store this information in the historical database.</p><p>In this way we achieved different things under the hood.</p><ul><li>We updated the light very fast without waiting for other micro-services</li><li>The user does not need to wait for the storage of micro-historical</li><li>We also stored the historical data</li><li>Micro-network does not have to worry about the storage of the historical data</li><li>We can optimize the storing of historical data by grouping multiple events together with a batch request</li><li>We can scale up micro-network (having for example 10 micro-network running at the same time), keeping the instances of micro-historical very low (3 instances)</li></ul><p>This elastic but reliable structure has been achieved thanks to <a href="https://nats.io/">NATS</a>: a fantastic tool the permit an easy communication between micro-services. Alternatives that we analyzed where Kafka or RabbitMQ, but even if more famous they were not necessary for the scope of our backend.</p><p><strong>Consistency of the code</strong></p><p>Another tough problem of a micro-service structure was how to maintain several micro-services. Some of the risky point where the following:</p><ul><li><strong>Avoid repetition of code:</strong> it is useless and dangerous to use different code on different micro-services. Fixes made on one micro-services risked to not be reflected on others.</li><li><strong>Output consistency:</strong> it would awful to have errors or list of identifier returned in different way in relation of the micro-service contacted.</li></ul><p>To avoid this problematic I created a subrepository called micro-core that includes all the operations in commune between the micro-services. In this I guaranteed that operations like validations, data structure, storing on the database, errors outputs, searching are made consistent between all our micro-services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-JcqxveJAWZoFfV0ZlRoIw.png" /><figcaption>An idea for the future — Bugs attack — the next Disney movie for developers!</figcaption></figure><p>Thanks to Ruby logic the micro-services can then overwrite the micro-core logic for its own purpose and provide more or less features in relation of the need.</p><p><strong>Concurrency</strong></p><p>A last interesting challenge on passing from micro to macro was handle concurrency. It can happens that two micro-services are updating the same data at the same time and this was a huge concern in the evolution of a micro-service structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ysjPS9QkdpCcd_B5erdcJA.png" /><figcaption>Developer that is ready to launch its pc after hitting a concurrency error</figcaption></figure><p>One important help in the fight against concurrency came by making the different micro-service strongly separated. For example micro-historical very rarely will modify objects concerning micro-network.</p><p>However with multiple instances of same micro-services running at the same time the editing of a same document it is not a rare occasion.</p><p>The chosen database Couchbase luckily offers an amazing way to handle <a href="https://docs.couchbase.com/ruby-sdk/current/howtos/concurrent-document-mutations.html">concurrent document modifications</a>. By storing the CAS I was able to create an efficient way that it handle concurrency without lose of information.</p><p>To achieve this, in case of concurrency error, I compare the data retrieved at the begin of the request, the data modified at the end of the request, and the changed data currently stored in the database. At the end the new element is a combination of these three documents.</p><p>I used the passage from macro to micro also to achieve many other improvements. I introduced a middleware logic, the validation system was drastically improved in performance and logic, threads were in general removed for a more modern approach with Fibers and so on.</p><p>Going deeper is for sure interesting, but I think that can be a topic for another time. Thank you for reading. Greetings!</p><p>All the pictures have been created by me with Stable diffusion.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abef8a0d9757" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wappsto — 1. How to make IoT easier]]></title>
            <link>https://medium.com/@stefanomartin/wappsto-1-how-to-make-iot-easier-bffbfa89f9d?source=rss-3ae71f5ee20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/bffbfa89f9d</guid>
            <category><![CDATA[hardware]]></category>
            <category><![CDATA[wappsto]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[internet-of-things]]></category>
            <dc:creator><![CDATA[Stefano]]></dc:creator>
            <pubDate>Tue, 27 Jun 2023 20:36:19 GMT</pubDate>
            <atom:updated>2023-06-27T20:41:47.458Z</atom:updated>
            <content:encoded><![CDATA[<h3>Wappsto — 1. How to make IoT easier</h3><p>Internet of Things was a powerful series of word some years ago before Machine Learning, Cryptocurrency, Artificial Intelligence, or NFT tried to take the crown. Lured by the beauty of that world, I landed in Seluxit, an amazing company focused on making IoT easier to clients, developers, and users. I would like to talk a little about Wappsto in this part of the blog.</p><figure><img alt="The scary Internet of Things" src="https://cdn-images-1.medium.com/max/1024/1*bYLG2Qq_dMymEIr86-TvrA.png" /><figcaption>How many people see the Internet of things — complex, scary, but beautiful</figcaption></figure><p>Since seven years ago, the world of technology evolved and transformed and Seluxit also changed with it. And at the top of this change there was Wappsto: a Web Application Store made to integrate easily all the parts that make hard the creation of an IoT product.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*Tk23OExP9ttjellsSvSELA.jpeg" /><figcaption><a href="https://wappsto.com/">https://wappsto.com/</a></figcaption></figure><ol><li><strong>Hardware level</strong></li></ol><p>One of the first challenge is how to connect in secure way your device to the IoT world. Wappsto not only provides its cloud solution, but it also give an hand to build the code that it will run on your hardware.</p><p>This can be achieved thanks to the Python library in this repository: <a href="https://github.com/Wappsto/python-wappsto-iot">Wappsto/python-wappsto-iot (github.com)</a>.</p><p>Where the Certificates can be obtained directly on Wappsto thanks to the IoT Certificate Manager.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*dNb1rYl00Gbb1-p4tQRedA.png" /></figure><p>2. <strong>Cloud level</strong></p><p>The second hard challenge is how to handle the data. Where to store geolocation? How to share data with my collegue? What is the historical of my data? Is my device online or not?</p><p>The library communicates directly with the backend of Wappsto. The API stores easily the information in two databases: one for store the object information as JSON schema (Couchbase), and the other one as historical data (CockroachDB). The reliability of these databases permit an easy way to see and understand the stored data.</p><figure><img alt="The vastity of the Cloud" src="https://cdn-images-1.medium.com/max/1024/1*NfHirAdgaSOkTjHnx57NeA.png" /><figcaption>Developer watching the vastity of the Cloud</figcaption></figure><p>With a wise handling of permissions the owner of the data can decide to share, delete, or increase the available data.</p><p>3. <strong>Application level</strong></p><p>After having the data are stored, it can be useful to create an application to show this data to the public in a way useful for the user. Here it comes the main strength of Wappsto, since every user can create a small or a big applications that then it will be published on an Internet store available to the public.</p><p>These applications do not necessary needs to be integrated with Wappsto hardware, but they can communicate easily with third party API thanks to Oauth communications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*Vdc1QNgd5SeUaklGClLR7g.png" /><figcaption>An example of Wapp that integrate with Tesla Wapp</figcaption></figure><p>4.<strong> Integration between products</strong></p><p>Finally there is the most important of every IoT product, i.e. the integration between the parts. Wappsto provides two great possibility: the first one is the creation of a Wapp. However this one can be challenging for the newbie, so an alternative is proposed.</p><p>This is Blocks. An interesting application that permits to create small application to integrate two or more applications or IoT networks between each others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*B8toV6w77AkWstxQjpHclQ.png" /><figcaption>Blockly for friends!</figcaption></figure><p>Wappsto is really interesting as a full stack I am happy to have helped in the creation of this platform. <br>Personally I helped in the creation of several application(for example the above TeslaWapp) and the full creation of the Wappsto API.</p><p>The two pictures above have been created by me by using Stable diffusion.</p><p>If you liked the post, please share with your friends and colleagues. Greetings!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bffbfa89f9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stable diffusion — 9. Controlnet: la potenza del movimento]]></title>
            <link>https://medium.com/@stefanomartin/stable-diffusion-9-controlnet-la-potenza-del-movimento-c49f5bbd53fe?source=rss-3ae71f5ee20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c49f5bbd53fe</guid>
            <category><![CDATA[controlnet]]></category>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[gioconda]]></category>
            <category><![CDATA[divertimento]]></category>
            <category><![CDATA[arte]]></category>
            <dc:creator><![CDATA[Stefano]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 18:53:21 GMT</pubDate>
            <atom:updated>2023-06-26T18:57:55.699Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stable diffusion — 9. Controlnet: la potenza del movimento</h3><p>Una delle cose più complesse nel creare immagini con AI è la creazione di immagini dinamiche o in posa. Si può scrivere un prompt del tipo: “Ragazza che salta allegramente” ma può essere particolarmente complesso raggiungere la posizione di salto che si desidera raggiungere.</p><p>A tale scopo viene in aiuto Controlnet. Questa è un’estensione di A1111 che propone diversi Controlnet models che permettono la creazione delle immagini con diverse tecniche a disposizione.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*6W-7D5xZz5B-HeP_r8pkDQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*u2O5fbThZQo1obMbo_BMBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*FJwRuNSOP8mqFcSJsIfkLQ.png" /><figcaption>Immagine reale (a sinistra), posa generata (centro), immagine creata dopo il prompt (a destra)</figcaption></figure><p><strong>Come installare Controlnet?</strong></p><p>Prima di tutto bisogna installare l’estensione (vedi anche il blog precedente a questo): <a href="https://github.com/Mikubill/sd-webui-controlnet">Mikubill/sd-webui-controlnet: WebUI extension for ControlNet (github.com)</a></p><p>Dopo di chè bisogna installare alcuni modelli che permettono di processare le immagini. Questi si trovano in questa cartella: <a href="https://huggingface.co/lllyasviel/ControlNet-v1-1/tree/main">lllyasviel/ControlNet-v1–1 at main (huggingface.co)</a></p><p>Salvate i file .pth e .yaml nella cartella “A1111 Web UI Autoinstaller\stable-diffusion-webui\models\ControlNet”. Vi chiederete quali scaricare se non volete installarli tutti? Beh… dipende da cosa volete ottenere. Se per esempio volete usare “openpose”, allora scaricatevi “control_v11p_sd15_openpose.pth”. Se volete usare “canny”, scaricatevi “control_v11p_sd15_canny.pth”.</p><p>Ma proviamo ad andare più nel dettaglio.</p><p>Per gli esempi sottostanti userò sempre la Gioconda come immagine base.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*EjYTBSrWrAM1eaQl6ktgkQ.jpeg" /><figcaption>Col suo sorriso enigmatico!!!</figcaption></figure><p><strong>Openpose</strong></p><p>Openpose è un metodo che permette di mettere uno o più personaggi nella posizione che si è deciso.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ETZO5NSIP5sQxeixIRV6XA.png" /></figure><ol><li>Cliccate sul TAB Controlnet (sotto all’opzione del Seed)</li><li>Cliccate su Enable</li><li>Dalla lista “Control Type” cliccate su OpenPose</li><li>Su Preprocess lasciate openpose_full se volete analizzare tutto il corpo, altrimenti scegliete il preprocessore che desiderate se volete focalizzarvi su volto o mani.</li><li>Scegliete il modello scaricato (dovrebbe essere già scelto di default)</li><li>Aggiungete l’immagine che volete selezionare</li><li>Se volete vedere una preview del preprocessore cliccate sul piccolo fuoco d’artificio vicino al menu del preprocessore.</li><li>Generate l’immagine</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*HDzFDCnR0Wwf_hbLOWAbuA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*G6P3oLcaZxTHxFoATahCRw.png" /><figcaption>Preprocessata, output col mio prompt di uomo anziano</figcaption></figure><p>Se non siete soddisfatti della posa ottenuta, potete modificarla dopo aver scaricato quest’estensione: <a href="https://github.com/fkunn1326/openpose-editor">fkunn1326/openpose-editor: Openpose Editor for AUTOMATIC1111’s stable-diffusion-webui (github.com)</a><br>Un piccolo pulsante “Edit” dovrebbe apparirvi nella preview pre-processata.</p><p>Se volete usare pose create da altri (Civitai è ricca di ciò), aggiungete la posa come un’immagine normale (punto 6), ma in preprocessore selezionate “none”.</p><p><strong>Canny</strong></p><p>Canny è carino perché riprende lo stile dell’immagine, ne estrae le linee principali e ricrea l’immagine seguendo lo stesso stile.</p><p>Il processo è simile a quello utilizzato per Openpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*Q-siLYmKqMBDyFgmt7Yh5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*zmW_V4qsgB1W4El_N2w4_g.png" /><figcaption>Preprocessata, output col mio prompt di donna con molti colori</figcaption></figure><p><strong>Scribble</strong></p><p>Un’alternativa a “canny” può essere scribble che trasforma l’immagine di partenza in uno splendido scarabocchio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*YLRjnOmbqW7d14JkQEY4uA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*6uWuueiOMwuGYnAavWj1CA.png" /><figcaption>Splendido scarabocchio e dopo aver messo il prompt sopra</figcaption></figure><p><strong>Depth</strong></p><p>Depth è simile a “canny”, ma invece di focalizzarsi sul bordo si concentra di più sulla “profondità” dell’immagine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*Jq41kwbsX7BEI4Fr81iyVA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*UdKkQ9xx8epScwPNHDEmtg.png" /><figcaption>Preprocessata, output col mio prompt di suora</figcaption></figure><p><strong>Lineart</strong></p><p>Questo preprocessore è anch’esso simile canny, ma il suo modo di prendere nota dei dettagli è più simile a tratti di penna o pennello. Il che può essere utile per ottenere immagini simil dipinto o fumetto. Ci sono diversi line art in relazione se si vuole andare su un livello più “anime” o “realistico”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*Yfx5C8kJqE-m3AkjpMjawA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*CTKffuhiUxUbFxGCeDnlFw.png" /><figcaption>Preprocessata, output come anime</figcaption></figure><p><strong>SoftEdge</strong></p><p>SoftEdge è un’altra tecnica basata sull’analisi dei bordi ma che crea un leggero bordo attorno all’immagine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*J5ebf0D1N1ivcXqYXaM0eA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*q8172y8H2VoMN7_HjBJtqQ.png" /><figcaption>Preprocessata e dopo con un tocco di Steampunk</figcaption></figure><p><strong>MLSD</strong></p><p>Qui invece ci concentriamo sulle righe dritte dell’immagine scelta. Visto che la Gioconda non ha una linea dritta neanche a pagarla d’oro il risultato è praticamente nullo. Posto ciò come esempio di utilizzo sbagliato di preprocessore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*Nrq9Sgks_LxKT5Dfs8nfaQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*zx-i9ii849gK3hWIoivgGw.png" /><figcaption>Preprocessata (da schifo) e immagine ottenuta</figcaption></figure><p>Qua con un esempio più interessante.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*lCnzufUN4DSXwJVv0defQw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*kTCHK4FD_BLbnx41KtR4xw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*l4i7kjP_65rwlDO9XR6Ibg.png" /><figcaption>Originale, preprocessata, nuovo con prompt</figcaption></figure><p><strong>Normal maps</strong></p><p>Normal maps si basano sull’orientazione della superfice. Molto simile all’effetto depths. Può essere utile se si vuole dare un’effetto tridimensionale all’immagine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*EV_6zebKfbiNdTCpibt6FQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*YqwXiIaS80IvgewZa2lLNQ.png" /><figcaption>Preprocessata e futurista</figcaption></figure><p><strong>Segmentation</strong></p><p>Segmentation divide l’oggetto cercando di dare una sturttura di referenza all’immagine.</p><p>Anche qua l’esempio col dipinto non rende bene, quindi ripropongo i palazzi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*lCnzufUN4DSXwJVv0defQw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*dAvTJNzWtkXxMHRq5kwdIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*UNyRh5pi_VB1_F8-vY3wTw.png" /><figcaption>Originale, preprocessata, immagine col prompt</figcaption></figure><p><strong>Shuffle</strong></p><p>Questo processore è utile per creare immagini con uno stile simile a quello di partenza. L’immagine viene mischiata e i colori più lo stile vengono riutilizzati in un’immagine completamente nuova.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*5lC5ppQHtKimxaeiAgTUTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*IiF-j7-zB7Mjtx0cfdeYNA.png" /><figcaption>Mix di Monalisa, la mia donna Steampunk con uno stile Leonardesco</figcaption></figure><p><strong>Reference</strong></p><p>Reference è una nuova serie di preprocessori che per NON utilizzano un Control model. Basta selezione il preprocessore. Questo serve per influenzare l’immagine che si vuole ottenere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*ATk2IwdZXys92STuh6QGkg.png" /><figcaption>La mia personale Mona Lisa</figcaption></figure><p>Ci sono altre tecniche quali</p><ul><li>Tile resample” per upscalare l’immagine</li><li>“inpaintint” per ritoccare le immagini con img2img</li><li>“T2IA” che utilizza template da Tencent: <a href="https://huggingface.co/TencentARC/T2I-Adapter/tree/main/models">TencentARC/T2I-Adapter at main (huggingface.co)</a></li><li>“IP2P” (non sono riuscito a trovare molta documentazione in proposito)</li></ul><p>Prometto che ci ritornerò quando andrò più sul dettaglio. Ciononostante credo che per oggi sia abbastanza e vi abbia offerto una buona descrizione di cosa si possa ottenere con quest’estensione.</p><p>Se vi è piaciuto il post condividete con amici e parenti. E ricordatevi di apprezzare il post!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c49f5bbd53fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stable diffusion — 8. Estensioni: rendiamo webUI grande]]></title>
            <link>https://medium.com/@stefanomartin/8-estensioni-rendiamo-webui-grande-267a550d2ecb?source=rss-3ae71f5ee20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/267a550d2ecb</guid>
            <category><![CDATA[estensione]]></category>
            <category><![CDATA[web-ui]]></category>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[arte]]></category>
            <category><![CDATA[controlnet]]></category>
            <dc:creator><![CDATA[Stefano]]></dc:creator>
            <pubDate>Tue, 20 Jun 2023 18:03:59 GMT</pubDate>
            <atom:updated>2023-06-22T07:40:52.115Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stable diffusion — 8. Estensioni: rendiamo webUI grande</h3><p>A1111 è un immenso prodotto, ma manca di alcune funzionalità che potrebbero essere utili per creare la propria immagine perfetta. Per questo come in altri programmi, quali Chrome o VSCode, esistono delle estensioni per A1111 per ampliare cosa si può ottenere con A1111.</p><p>Una lista di estensioni disponibili è presente qua: <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Extensions">Extensions · AUTOMATIC1111/stable-diffusion-webui Wiki (github.com)</a></p><p><strong>Installazione</strong></p><p>Per installare un estensione ci sono due metodi: una “facile” e una più da programmatori. Quella facile è molto semplice:</p><ol><li>Clicca sul tab “Extensions”</li><li>Clicca su “Available”</li><li>Clicca su “Load from”</li><li>Dalla lista sottostante clicca su “Install” per installare l’installazione desiderata (si può andare sulla pagina dell’estensione cliccando sul nome dell’estensione).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5pbzp4iJv2sIW56L_aHBuA.png" /><figcaption>Qua i vari passi in un’immagine.</figcaption></figure><p>In alternativa potete andare nella pagina Github dell’estensione, copiare l’url dalla barra in alto e usare l’opzione “Install from URL”.</p><p>La versione installazione da programmatori si basa di più sull’utilizzo di Git.</p><ol><li>Apri il terminale</li><li>Va nella cartella “A1111 Web UI Autoinstaller\stable-diffusion-webui\extensions”</li><li>Usa “git clone [url del repository dell’estensione]”</li></ol><p>Per disinstallare un estensione bisogna andare nella cartella delle estensioni “A1111 Web UI Autoinstaller\stable-diffusion-webui\extensions” e cancellare manualmente l’estensione che si vuole rimuovere.</p><p>Le estensioni si dovrebbero aggiornare al momento d’avvio di A1111 webui, se così non fosse potete aggiungere cliccando “Check for updates”.</p><p>Ci sono numerose estensioni ed è impossibile fare una lista di quelle più utili. Ciononostante voglio offrire una piccola panoramica di quelle che uso personalmente.</p><p><strong>Prompt translator</strong></p><p>LINK: <a href="https://github.com/ParisNeo/prompt_translator">ParisNeo/prompt_translator: A stable diffusion extension for translating prompts from 50 languages. The objective is to give users the possibility to use their own language to perform text prompting. (github.com)</a></p><p>Quest’estensione permette di tradurre in inglese i propri prompt dal vostro idioma. Questo permette di superare la barriera linguistica di questo programma.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nOKU3Gg8oOS6OFbZENHaqw.png" /><figcaption>Prompt in italiano (in rosso), tab e opzioni da selezionare (in verde)</figcaption></figure><p><strong>Lycoris</strong></p><p><a href="https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris">KohakuBlueleaf/a1111-sd-webui-lycoris: An extension for stable-diffusion-webui to load lycoris models. (github.com)</a></p><p>Lycoris sono “Lora beYond Convetional methods” e, se siete familiari con civitai, usati per modificare ulteriormente le vostre immagini. Sono ottimi tool che però non sono sfruttati nativamente da A1111 webui.</p><p>Installazione e utilizzazione è praticamente simile ai classici Lora.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sTDOPvFPmDPwOOQxcGmhBw.png" /><figcaption>Un nuovo tab è aggiunto fra i modelli</figcaption></figure><p><strong>Controlnet</strong></p><p><a href="https://github.com/Mikubill/sd-webui-controlnet">Mikubill/sd-webui-controlnet: WebUI extension for ControlNet (github.com)</a></p><p>Sicuramente farò un blog post dedicato a Controlnet, ma vale la pena introdurre già qua. Controlnet permette di partire da un’immagine base e ricreare una nuova immagine con una simile posizione ed il prompt designato.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mxbiLj--c5bmzqb2bDx-4Q.png" /><figcaption>Il nostro webUI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*NQpDQ8JFM5ryVfotS3OoVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*LI0v5T-ZXSuCW5TducadYg.png" /><figcaption>Prompt: A man holding a cup of tea</figcaption></figure><p><strong>Tag autocomplete</strong></p><p><a href="https://github.com/DominikDoom/a1111-sd-webui-tagcomplete">DominikDoom/a1111-sd-webui-tagcomplete: Booru style tag autocompletion for AUTOMATIC1111’s Stable Diffusion web UI (github.com)</a></p><p>Molto utile per aggiungere termini e suggerimenti su parole che si possono inserire nel proprio prompt. Molto consigliato per migliorare il proprio style.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y3N9Nz0j-X59aUwBQilBfw.png" /><figcaption>Un piccolo menu con parole suggerite appare mentre si scrive</figcaption></figure><p><strong>Prompt dinamici</strong></p><p><a href="https://github.com/adieyal/sd-dynamic-prompts">adieyal/sd-dynamic-prompts: A custom script for AUTOMATIC1111/stable-diffusion-webui to implement a tiny template language for random prompt generation (github.com)</a></p><p>Estensione necessaria se si vogliono provare differenti stili o se si vogliono usare wildcards (cioè un file con diverse combinazioni) che permettono la creazione di diversi output in un colpo solo. Questo può essere utile se Matrix prompt e X/Y/Z plot non sono sufficienti per ciò che si vuole ottenere.</p><p>Prompt: A {man|woman} holding a cup of tea ← Notate le grafe che rendono il prompt dinamico.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V6UDq_fMluIKXmJcv_0CBg.png" /><figcaption>Ed ecco le mie due creazioni (ho lasciato Controlnet attivato)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6zgPVKk1XPSwt7YCzH1AeQ.png" /><figcaption>In rosso dove premere</figcaption></figure><p><strong>Prompt generator</strong></p><p><a href="https://github.com/adieyal/sd-dynamic-prompts">adieyal/sd-dynamic-prompts: A custom script for AUTOMATIC1111/stable-diffusion-webui to implement a tiny template language for random prompt generation (github.com)</a></p><p>Se avete appena iniziato e non sapete come creare un buon prompt, questa estensione può essere un buon punto di partenza. Scrivete un prompt corto corto e l’estensione vi genera quattro prompt più complessi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8quO1B9Gm5TgT7OykX8PkQ.png" /><figcaption>Mio prompt (freccia rossa), prompt in uscita (freccia verde)</figcaption></figure><p>Di estensioni ce ne sono anche di più, da quelle che creano QR codes a quelle che fanno video, da altre che cambiano l’interfaccia grafica ad altre che aiutano nel gestire i modelli. Sperimentate e provate fino a che non avete ottenuto il vostro programma preferito.</p><p>Un saluto! Se vi piace cliccate sul battimani sottostante e condividete con amici e parenti! Ciao! 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=267a550d2ecb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stable diffusion — 7. Fra Lora, textual inversion e iper network]]></title>
            <link>https://medium.com/@stefanomartin/fra-lora-textual-inversion-e-iper-network-5667bf0b5eeb?source=rss-3ae71f5ee20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5667bf0b5eeb</guid>
            <category><![CDATA[hyper-network]]></category>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[arte]]></category>
            <category><![CDATA[lora]]></category>
            <category><![CDATA[text-inversion]]></category>
            <dc:creator><![CDATA[Stefano]]></dc:creator>
            <pubDate>Fri, 09 Jun 2023 21:23:09 GMT</pubDate>
            <atom:updated>2023-06-22T07:40:22.262Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stable diffusion — 7. Fra Lora, textual inversion e iper network</h3><p>Continuando il nostro viaggio nella scoperta di Stable diffusion, ritengo impossibile non parlare dei Lora model. <br>Come abbiamo visto i modelli è praticamente l’intelligenza della nostra AI.<br>Ma supponiamo che vogliamo insegnare alla nostra AI solo piccoli concetti: quali aggiungere piccoli dettagli, settare uno stile o mettere un personaggio famoso particolare. Come fare?</p><p>Per rispondere a questa domanda: ci sono i Lora. Piccoli modelli di pochi Megabytes che permettono di modificare il proprio prompt con facilità. Inseriscono dei nuovi layer nel modello e permettono di migliorare le modalità di cosa si vuole ottenere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Zi-R8hdI6ordlkTRAASQw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dngvluNdESnMyCrRigiZlg.png" /><figcaption>A destra con una Lora per i dettagli</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5F9J32NCeK1fD_cYnm9LPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SZg0K-8ZYDr4Jb9z0yvOJw.png" /><figcaption>A destra con una Lora per Steampunk style (nota che anche a sinistra ho usato una key steampunk)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zCTg1wnf406BkZXq70pdYw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZpOkSjALmvs-D7QZuYjOoA.png" /><figcaption>A dstra con una Lora per la principessa Peach (nota che anche a sinitra ho usato una key per Principessa Peach)</figcaption></figure><p>Le Lora hanno un loro peso e possono essere graduate con un valore da 0 a 1 in relazione in quanto vogliamo che abbiano effetto.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V3fY3yL6JogHyrvLpiI5Yg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nB9xCjgzMHsQHm8PNjEjIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*brTLqGlZhYq5kKzyj869Tw.png" /><figcaption>Con Lora warrior, valore a 0 (sinistra), 0.5 (centro) e 1 (destra)</figcaption></figure><p>Inoltre molte Lora iniziano ad avere effetto solo se una qualche parola chiave è usata nel prompt. Date un’occhiata alla descrizione della Lora per comprendere che parole chiave usare.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gl3j8VQRzQUPrt-y6gIqFQ.png" /><figcaption>Vedete la freccia rossa nel caso di Civitai</figcaption></figure><p>Per poter usare una Lora, scaricate da Civitai o da Huggingface e invece di salvarla nella cartella Stable diffusion, salvate nella cartella chiamata “Lora”. In “A1111 Web UI Autoinstaller/stable-diffusion-webui/models/Lora”.</p><p>Un’altra tecnica interessante è il Textual Inversion. I file che gestiscono Textual Inversion sono molto piccoli, sull’ordine di Kilobyte (ricordo Lora sono sui 120 MB in genere, e i modelli sui 2 GB) e possono modificare anch’essi l’immagine con facilità.</p><p>Al contrario di un modello o di un Lora, il Textual Inversion si applica sul prompt e quindi viene dato in pasto all’AI che la utilizza per generare l’immagine. Per questo motivo non è sorprendente che non solo esistano Textual Inversion for prompt “normali”, ma anche per i prompt “negativi”.</p><p>E’ straordinario il funzionamento del Textual Inversion in quanto semplicemente prepara la “logica” delle parole prima di darlo in pasto al modello. E’ quindi importante che il modello conosca il Textual Inversion che gli viene proposto.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TuhME5dkEvdPonoyq3LyLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OLEF9o6DmD0pKZ-mhzvnVw.png" /><figcaption>A destra con una serie di textual inversion (negativi e positivi)</figcaption></figure><p>I Textual inversion devono essere salvati in “A1111 Web UI Autoinstaller/stable-diffusion-webui/embeddings”. Notate che, al contrario della Lora, questi sono salvati nella cartella “embeddings”. Lo dico per rimarcare che questa tecnica non si basa sull’utilizzo di un modello.</p><p>Infine un’altra tecnica è Hypernetwork. Che è un po’ come i Lora, ma che si basa sul concetto di creare il Lora quasi sul momento con un veloce processo di Machine Learning e di usarli con il modello per ottenere ciò che si vuole.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*djlo8JuNtkhHLSdXxhtXfQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKR465XBT0WbfYnddvj1Ug.png" /><figcaption>Con hyper network (a destra)</figcaption></figure><p>Gli Hypernetwork devono essere salvati in “A1111 Web UI Autoinstaller/stable-diffusion-webui/models/hypernetworks”.</p><p>Un buon video che spiega questi concetti è il seguente.</p><p><a href="https://www.youtube.com/watch?v=dVjMiJsuR5o">😕LoRA vs Dreambooth vs Textual Inversion vs Hypernetworks — YouTube</a></p><p>Dreambooth, in questo contesto comunque sono i nostri consueti modelli.</p><p>In conclusione io consiglio di usare Textual Inversion per gestire stile e dettagli e il Lora per i cambiamenti maggiori. Ciononostante tutto una combinazione di tutti è più che buona e sperimentare è sempre cosa buona e giusta!</p><p>Direi che per oggi è tutto: si vi è piaciuto il post, battete le mani cliccando sull’iconcina a fine post e condividete con amici e parenti. Un saluto!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5667bf0b5eeb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stable diffusion — 6. Vediamo come migliorare la nostra immagine]]></title>
            <link>https://medium.com/@stefanomartin/stable-diffusion-6-vediamo-come-migliorare-la-nostra-immagine-aec24c4fa748?source=rss-3ae71f5ee20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/aec24c4fa748</guid>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[immagini]]></category>
            <category><![CDATA[arte]]></category>
            <category><![CDATA[migliorare]]></category>
            <category><![CDATA[sampling]]></category>
            <dc:creator><![CDATA[Stefano]]></dc:creator>
            <pubDate>Sun, 04 Jun 2023 20:35:24 GMT</pubDate>
            <atom:updated>2023-06-04T20:35:24.579Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stable diffusion — 6. Vediamo come migliorare la nostra immagine</h3><p>In quests sezione vediamo un po’ di tecniche e opzioni su cui lavorare con l’immagine.</p><h3>CFG Scale</h3><p>Il “Classifier-free guidance scale” serve per dire all’AI quanto deve seguire il prompt.</p><p><strong>1–3</strong>: Completamente distante dal prompt desiderato<br><strong>4–6</strong>: Molto creativo ma è possibile che molte parti del prompt possano essere ignorate<br><strong>7–10</strong>: Solitamente un buon bilanciamento fra prompt e cosa si vuole ottenere<br><strong>11–15</strong>: Se proprio vuoi essere sicuro sicuro di ottenere ciò che si vuole, il prompt deve essere molto molto dettagliato<br><strong>16–20</strong>: Il prompt dev’essere scritto in maniera esageratamente dettagliata. Coerenza e qualità potrebbe andar persi.<br><strong>&gt;20</strong>: Disastro, praticamente inutilizzabile</p><p>Prompt: <em>Keanu Reeves as Johnny Silverhand, holding a (cat), Best quality, masterpiece, ultra high res, (photorealistic:1.4), raw photo, 1man, 1man , cyberpunk, (pilot sunglasses), techwear outfit, dynamic pose, looking at viewer, from below, best shadow,intricate,depth of field,long hair,messy hair, Tokyo city background, night city<br></em><strong>Modello</strong><em>: ICBIN</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*bqAaJdzoLhb1FBIC6Lg2Pg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*Qk870hAgBSojHeCVC3CpXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*zd376nGAdS19W7_R1ysEHw.png" /><figcaption>CFG 1 (a sinistra), 4 (centro), 7 (a destra)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*E37DQXh7kcYzHOv5_uN53A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*BQWloiqy1qsNmuvtPT44_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*SX-P1TF212hig80GYAth2g.png" /><figcaption>CFG 11 (a sinistra), 16 (centro), 25 (a destra)</figcaption></figure><p>Prompt: <em>man playing chess, (Highest picture quality), (Master’s work), (ultra-detailed), (Detailed eye description:1.2), masterpiece,best quality,absurdres,original, (masterpiece:1.4),(best quality:1.4)<br></em><strong>Modello</strong><em>: Anything V5</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ek6QXeEDmqOhnMLNfMC2rA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*v65WZh25YpTwBXFBC4LoMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*lD6uFSicitZYtp_5zIL1lQ.png" /><figcaption>CFG 1 (a sinistra), 4 (centro), 7 (a destra)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*V5UC8iN08P3zZ1QJhg_Wzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*1v9tOloRKgHsoLvaAYiaBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*RIIkyymGCWek9t_5nIGrhA.png" /><figcaption>CFG 11 (a sinistra), 16 (centro), 25 (a destra)</figcaption></figure><p>In genere credo che lasciare una fantasia fra il 6 e il 7 dia i migliori risultati (specie in fase di creazione). Ciononostante sono sorpreso dalla trasformazione nel modello Anything dove si passa ad uno stile più moderno. Vale la pena sperimentare dopo aver fissato il seed.</p><h3>Sampling steps</h3><p>“Samplings steps” denota quanti passi deve Stable Diffusion eseguire per passare da uno stato casuale all’immagine del prompt.</p><p>Più si aumentano gli steps, più dovrebbe aumentare la precisione con un costo di tempo che, a volte, non dà necessariamente i risultati voluti.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*KqSWxzSeNPNn3ISlY9E19Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*aq86WOBHl6LjlGu6CvQ6iQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*-IdLsfsfBrG5T-ZWkyYwog.png" /><figcaption>Steps 1 (a sinistra), 5 (centro), 10 (a destra)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*rkQD5FA30t3V14ZYELs8Ew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*Y-zv4b2ZhjpZUegeQoTeZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*X-doODdRsoJCyUSHS7lYYA.png" /><figcaption>Steps 20 (a sinistra), 50 (centro), 100 (a destra)</figcaption></figure><p>Stesso prompt, modello fotografico</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*DasKJV0P2BcW3qy_iQhl2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*uMeW6FMJ0srs-mK1nUjAbg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*BBJTHKR0ub8Fy6ndzCCl8w.png" /><figcaption>Steps 1 (a sinistra), 5 (centro), 10 (a destra)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*c5WyhXOreJ8aplBBIb4c2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*vi5-LnQdmhZKuzonq1avfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*OXC2hzTpT1TIXsqkr-MwmQ.png" /><figcaption>Steps 20 (a sinistra), 50 (centro), 100 (a destra)</figcaption></figure><p>Come credo si può comprendere dalle immagini, fino a circa 20 steps non si riesce a raggiungere un risultato realmente soddisfacente (benché già a 10 ci sono discreti risultati). Da 20 steps in su le differenze si assottigliano.</p><p>Il mio consiglio è di testare i prompt con un sampling steps di 20 e, quando soddisfatti, fissare il seed e magari alzare il sampling steps a 50.</p><h3><strong>Sampling method</strong></h3><p>Come abbiamo appena visto, il sampling è l’atto di passare da uno stato casuale ad un’immagine vera e propria seguendo il prompt dato. Per ottenere ciò ci sono diverse tecniche che hanno i loro vantaggi e svantaggi in termini di prestazione, VRAM usata e tempo che necessitano per compilare.</p><p>Per questa parte della guida prendo spunto da quest’ottimo tutorial in inglese di <a href="https://stable-diffusion-art.com/samplers/">Stable-diffusion-art</a>.</p><p>Al momento conto ben 23 algoritmi (di più di quelli dell’articolo) per poter fare il sampling.</p><p>Prompt: <em>(masterpiece, best quality),1girl with long white hair sitting in a field of green plants and flowers, her hand under her chin, warm lighting, white dress, blurry foreground, dark skin<br></em><strong>Sampling steps:</strong><em> </em>50</p><p>Sampler vecchia scuola:</p><ul><li><strong>Euler</strong>: Il sampler più semplice</li><li><strong>Heun</strong>: Una versione più accurata, ma più lenta do Euler</li><li><strong>LMS </strong>(Linear multi-step method): Stessa velocità di Euler, ma tendenzialmente più accurato.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*Q0wW0ZJNlh7ts9lZ2-6e1Q.png" /><figcaption>Praticamente tutti e tre danno lo stesso risultato in tempi molto simili</figcaption></figure><p><strong>Sampler ancestrali</strong>: questi sono quelli che hanno una piccola “a” nel loro nome. Per esempio Euler a, DPM2 a, o DPM2 a Karras. Questi sampler sono stocastici, cioè aggiungono sempre una certa casualità ad ogni passo e quindi non convergono necessariamente all’immagine che si vuole raggiungere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*05N8N7ZrXcEW9q_uIfFvPQ.png" /><figcaption>Generato con Euler A</figcaption></figure><p><strong>Karras</strong>: I samplers con dentro “Karras” usa un metodo di analisi del rumore di fondo basato da un articolo di <a href="https://arxiv.org/abs/2206.00364">Karras</a>. Questo dovrebbe aiutare nella qualità dell’immagine.</p><p><strong>DDIM </strong>(Denoising Diffusion Implicit Model) and <strong>PLMS </strong>(Pseudo Linear Multi-Step method): DDIM è uno dei primi solver creato per Stable Diffusion 1. PLSM è più nuovo e veloce del predecessore. Entrambi sono considerati obsoleti.</p><p><strong>DPM </strong>(Diffusion probabilistic model solver) family: sono una serie di samplers creati per modelli del 2022. Hanno un’architettura simile. <br>DPM2 (secondo ordine) è più accurato, ma più lento di DPM. <br>DPM++ è un miglioramento di DPM.<br>DPM adaptive aggiusta i passi in maniera adattiva (può essere lento perché non garantisce di raggiungere il risultato voluto entro un determinato numero di passi).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*29cMfVNZH5fUW4ynLQHjDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*SuYGgyrVTB7T6AJjzQkHgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ayO9W34yatXwrnz3x6VULg.png" /><figcaption>DPM fast (a sinistra), DPM adaptive (centro), DPM2 a Karras (a destra)</figcaption></figure><p><strong>UniPC Unidifed Predictor-Corrector)</strong> è un nuovo sampler creato nel 2023. Dovrebbe raggiungere immagini d’alta qualità in 5–10 passi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*Vme4ypAOCL6kc201lhqpHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*U9fIBNALQXWvGt5zTzGa_A.png" /><figcaption>UniPC in 10 passi (a sinistra) e 50 passi (a destra)</figcaption></figure><p>Alla fin fine comunque come si può vedere dalle immagini, i vari sampler tendono a convergere ad una determinata immagine. Ma quale converge meglio e più in fretta?</p><p>I risultati di stable-diffusion-art sono i seguenti:</p><ul><li>Se si vuole qualcosa di veloce, convergente, nuovo e con buona qualità: utilizzate DPM ++ 2M Karras con 20–30 steps, o UniPC con 20–30 steps</li><li>Se si vuole buona qualità, ignorando la convergenza, buone scelte sono : DPM++ SDE Karras con 8–12 steps (è un po’ lento) o DDIM con 10–15 steps.</li><li>Evitate sampler ancestrali se si desidera riprodubili immagini.</li><li>Euler ed Heun sono sempre delle buone opzioni da dove iniziare in maniera semplice.</li></ul><p>Spero che quest’articolo sia stato abbastanza interessante. Se vi è piaciuto condividete con amici e parenti. Un saluto. 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aec24c4fa748" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stable diffusion — 5. Un mese di progressi]]></title>
            <link>https://medium.com/@stefanomartin/stable-diffusion-5-un-mese-di-progressi-255865b32fe9?source=rss-3ae71f5ee20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/255865b32fe9</guid>
            <category><![CDATA[progressi]]></category>
            <category><![CDATA[nintendo]]></category>
            <category><![CDATA[esperimento]]></category>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[evoluzione]]></category>
            <dc:creator><![CDATA[Stefano]]></dc:creator>
            <pubDate>Sat, 27 May 2023 14:05:45 GMT</pubDate>
            <atom:updated>2023-05-27T14:35:18.613Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stable diffusion — 5. Un mese di progressi</h3><p>Ora è da circa un mese che ho iniziato ad utilizzare Stable diffusion e credo di aver fatto buoni progressi. Questo post è fatto per mostrare i progressi fatti in un mese. Ho scelto un paio di immagini per ogni giorno e ho cercato di evitare di ripostare immagini già inseriti nei post precedenti di questo blog.</p><h3>30 Aprile 2023 — L’inizio</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*HefO3h-3Yfk1KDDOryXESQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wFbnNDKp-D7Ikz5hreo8Cg.png" /></figure><h3>7 maggio 2023 — S’inizia a fare sul serio</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*7uKmiupQiASCKU28aWx1BA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*9v67LwKfTquIOCnVz4ssZw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*z4490qSDD2bGg8LNkis-xQ.png" /></figure><h3>8 maggio 2023 — Fra Berserk e supereroi</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*86wmOPhtxdcGfSQfcjfRPg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ZIQfwpdZcvm24MXuxCCprw.png" /></figure><h3>12 maggio 2023 — Villaggi</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*LcBmDcPph7oQMuhTM2XwPg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*bJFtbpjXIDpCQJjNr2FyeA.png" /></figure><h3>15 maggio 2023 — Astronauta su barca</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*IShl9mf739qTgK0XtqSeCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*iWody_woDvqMC7oqQ9_-4A.png" /></figure><h3>17 maggio 2023 — Lego e film per bambini</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*C65SdtITmU0do1mcGIMQpg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*MzMMIxH74AzIG0NVE0f4JA.png" /></figure><h3>19 maggio 2023 — Ragazze, manga e steampunk</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*YyiwA_7IQ059vZGgU7qJ2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*lQkmSYL2BQJ3aIflmirz0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*nHi7ofCmD3f_vWbXg9mFlQ.png" /></figure><h3>22 maggio 2023 — Castelli</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*_R7IfCO_zHPITds8Gh8QAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*QoYOiaHDufx31DcLARJ7yQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*uNo44Q5-2pdojej_VaVmXQ.png" /></figure><h3>23 maggio 2023 — Peach</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*-dZ2q3_Aovtzqz_3zR9atQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*4-oL8sWdivVnyEYTd9iMSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*mzcALfELIBob9WeBS5EEEA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*rB7wLeAENFXYW0iNeLBzUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ckO5ei6jd3LnwmCDRUSOag.png" /></figure><h3>25 maggio 2023 — Zelda</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wJKze1TvKSH4jQDYCJd-QA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*0c3AVzpVs0WJPcxw1SVxtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dsm3cMTvWroEJim5aATvqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*kpQKnmE9ZuN3ZV1yNRcjog.png" /></figure><h3>26 maggio 2023 — Samus</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*xAF2vIvOpm6DWRx_E8XC3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*2QZCqRJ8Gso2JtOgmdzuew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*b1BrlsMuCpxyrRwv0m2XbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DOBbfwPAhC3DHbQxaRlKGQ.png" /></figure><p>E si è arrivati finalmente ad oggi. Ho imparato un bel po’ e ne avrò ancora da scrivere su questo blog. Spero che le immagini postate vi siano piaciute e che condividiate con me le vostre opere.</p><p>Se vi è piaciuto questo post condividete con amici e parenti, un saluto! 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=255865b32fe9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stable diffusion — 4. Prova e riprova]]></title>
            <link>https://medium.com/@stefanomartin/stable-diffusion-4-prova-e-riprova-aa765e0433ac?source=rss-3ae71f5ee20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa765e0433ac</guid>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[prompt]]></category>
            <category><![CDATA[arte]]></category>
            <category><![CDATA[batch]]></category>
            <category><![CDATA[tecniche-di-disegno]]></category>
            <dc:creator><![CDATA[Stefano]]></dc:creator>
            <pubDate>Wed, 24 May 2023 20:43:18 GMT</pubDate>
            <atom:updated>2023-05-27T11:44:50.196Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stable diffusion — 4. Prova e riprova</h3><p>Creare un buon prompt con delle discrete idee può essere complesso. Spesso per ottenere un’immagine decente bisogna provare e riprovare, cercare la tecnica migliore ed avere un pizzico di fortuna.<br>Fortunatamente esistono delle tecniche che possono aiutare in questa profonda ricerca.</p><h3>Dove sono le mie immagini?</h3><p>Prima di iniziare vi voglio ricordare che tutte le immagini che generate possono essere trovate nella cartella di Stable diffusion UI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*TyVTIjrx4LgNSCAJTO4o-w.png" /></figure><p>Nel mio caso è in Documents/A111 Web UI Autoinstaller/stable-diffusion-webui/outputs/txt2img-images.</p><p>Magari non lo sapevate. 😜</p><h3>Il seed della situazione</h3><p>Uno dei concetti più interessanti quando si genera un’immagine è il “seed” (o seme in inglese). Praticamente ogni volta che generate un’immagine Stable diffusion aggiunge un valore casuale per aumentare il fattore randomico dell’immagine. Questo garantisce che ogni volta premiate “Generate” si crei un’immagine casuale.</p><p>Ma supponiamo che dopo un po’ di ricerche troviate un’immagine che finalmente vi soddisfi <strong>quasi </strong>completamente. Vorreste cambiare il prompt ma continuando ad utilizzare la stessa immagine con pochi cambiamenti. Come fare? Beh… il trucco è fissare il “seed”. Così facendo l’intelligenza artificiale è consapevole di non doversi troppo discostare dall’opera scelta e voi potete cambiare l’immagine un po’ come desiderate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*qGOEoTy-WomL4KJa4Wj1Gg.png" /><figcaption>Il pulsante col dado (freccia rossa) è fatto per usare un seed casuale, i.e. -1. Il pulsante della raccolta differenziata (freccia verde) è per riciclare il seed usato per l’ultima immagine creata.</figcaption></figure><p>Per esempio: immagine originale.<br>Prompt: <em>A nice girl walking in a city, star \(sky\), (smile), full body, very detailed face, very detailed clothes</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YAW90ciuhV-lzbmR7OV84Q.png" /></figure><p>Ora supponiamo che voglio queste due ragazze bionde.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vxeYO9r5800tCtCt2R0UKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aSh_3OZ_GA2_0G2XZsJu1A.png" /><figcaption>Col seed fisso (a sinistra), col seed casuale (a destra)</figcaption></figure><p>Forse l’immagine a destra (col seed -1, cioè casuale) è migliore di quella a sinistra, ma come potete vedere l’immagine a sinistra cerca per lo meno di seguire lo stesso stile dell’immagine sovrastante.</p><h3>Creare multiple immagini in fretta</h3><p>Per il vostro scopo potreste voler generare molte immagini in pochi secondi. Ci sono diverse maniere, una di queste è di usare le opzioni “Batch count” e “Batch size”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/1*LWr9LGmBk9YfTEqwnA0Dbw.png" /></figure><p><strong>Batch size</strong>: denota il numero di immagini che potete creare allo stesso tempo.<br><strong>Batch count</strong>: denota il numero di immagini che vengono create una in seguito all’altro.</p><p>Se settate batch size 2 e batch count 3, avrete come output 6 immagini.<br>Usando una metafora: batch size è il numero di biscotti che potete mettere in forno (nel nostro caso 2) e batch count il numero di volte che usate il forno (nel nostro caso 3). Per un totale di 6 biscotti.</p><p>Tenete conto che avere un “Batch size” alto può essere costoso in termini di VRAM perché denota il numero di operazioni eseguite allo stesso tempo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r4W1eOsG5UAk0K-WFKBAgA.png" /><figcaption>Interessante notare che i seed in questo caso sono molto vicini fra di loro</figcaption></figure><p>Altra possibile alternativa è premere col pulsante destro del mouse su “Generate” e cliccare “Generate forever” per iniziare a creare immagini a ripetizioni finche non si ferma il tutto con “Cancel generate forever”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*tzLeKjNDJtD9lKo99OseVg.png" /></figure><h3>Prompt matrix</h3><p>Supponiamo che nel vostro prompt avete dei dubbi e volete provare a confrontare diversi casi. Potete usare Prompt Matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*HyPgUzkI4eN3hxjWYD4scg.png" /></figure><p>Dividendo il prompt con una barra verticale | potete generare diversi prompt che analizzano i diversi casi analizzati. Per fare un esempio:</p><p>Prompt: <em>A nice girl walking in a city, star \(sky\), (smile), full body, very detailed face, very detailed clothes | blonde hair | hat</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MGJY694OyHSEIi-lnIK7ww.png" /><figcaption>4 prompt diversi che uniscono le quattro diverse situazioni (escludendo entrambe, considerando solo uno dei casi, o includendo entrambe le situazioni)</figcaption></figure><h3>Salvare e recuperare un prompt</h3><p>Per salvare un buon prompt cliccate sull’icona del floppy disk sotto Generate. Questo aggiungerà il vostro prompt nel menù styles sottostante. Per utilizzare uno o più stile, selezionate dal menù quelli che più volete e quindi premete sull’icona con la pagina aperta.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*6ZAnGF46qlkaAgfAGEPzCg.png" /><figcaption>Per salvare premete il floppy disk (freccia verde), per usare il prompt premete l’icona con la pagina (freccia rossa)</figcaption></figure><p>Può capitare per disgrazia che chiudete Stable Diffusion senza salvarvi il prompt perdendo magari ore di lavoro. Fortunatamente potete recuperare molte informazioni dalle immagini che avete creato finora.</p><p>Cliccate su PNG Info e quindi uploadate la vostra immagine nel sistema. Tutti i parametri dovrebbero apparvi sul lato. Cliccate su “send to txt2img” e continuate a lavorare col vostro prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AZaWZmhI-G9UZXajeldYNQ.png" /></figure><p>E con questo direi che è tutto! Grazie per la vostra attenzione. Se vi è piaciuto condividete con amici e parenti e magari aggiungete qualche applauso. Saluti!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa765e0433ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stable diffusion — 3. La bellezza dei modelli]]></title>
            <link>https://medium.com/@stefanomartin/stable-diffusion-3-la-bellezza-dei-modelli-db4b4c9b4ce2?source=rss-3ae71f5ee20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/db4b4c9b4ce2</guid>
            <category><![CDATA[arte]]></category>
            <category><![CDATA[modelli]]></category>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[civitai]]></category>
            <category><![CDATA[girasoli]]></category>
            <dc:creator><![CDATA[Stefano]]></dc:creator>
            <pubDate>Sun, 21 May 2023 20:04:12 GMT</pubDate>
            <atom:updated>2023-05-27T11:46:30.345Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stable diffusion — 3. La bellezza dei modelli</h3><p>Nella passata sezione mi sono focalizzato sulla creazione dei prompt. Questo può bastare se ci si focalizza soltanto sui modelli basilari tipo Stable diffusion v1.5 o Stable diffusion v2.1, però se si vuole qualcosa di migliore il mio consiglio di guardarsi altrove.</p><p>Se per esempio vogliamo fare qualcosa relativo a manga, è meglio utilizzare il modello <a href="https://civitai.com/models/9409/anything-v3">Anything V5</a>, se si vuole creare foto è meglio andare con <a href="https://civitai.com/models/28059/icbinp-i-cant-believe-its-not-photography">ICBINP</a>, se si vuole creare un libro per bambini <a href="https://civitai.com/models/64544?modelVersionId=69192">Children stories</a> è consigliabile.</p><p>Ma cos’è un modello? E’ perché ci serve per creare delle immagini più vicini allo stile che desideriamo?</p><p>Provate a pensare ad un modello come all’intelligenza dell’Intelligenza Artificiale. Le fate guardare un mezzo zillione di foto, lei cerca d’imparare più che può dalle immagine che le propinate e dopo un po’ le dite STOP. Va bene così. Ecco! Avete qua un modello che l’AI userà per creare delle immagini per voi.</p><p>Non credo che sia un caso che la vecchia estensione di modelli fosse <strong>.ckpt</strong>, come checkpoints. Questa estensione ora è considerata insicura, ove <strong>.safetensor</strong> è molto più apprezzato.</p><p>Stable v1.5 e Stable v2.1 sono alla base della maggior parte dei nuovi modelli. La community sceglie uno dei due modelli iniziali e ci costruisce sopra un nuovo modello (per esempio per creare manga).</p><ul><li>Stable v1.5: è un modello meno recente, ma è allenato anche su immagini protette da copyright e nswf. Ottimo se volete seguire lo stile di un artista specifico.</li><li>Stable v2.1: è un modello più recente, è più attento al copyright e ad immagini nsfw. Ciononostante produce immagini più realistiche e dettagliate di Stable v1.5.</li></ul><h3>Alcune foto con lo stesso prompt</h3><p>Per comprendere la differenza fra diversi modelli credo che sia esemplare cercare di produrre lo stesso prompt con diversi modelli.</p><p><strong>Prompt:</strong> <em>A nice girl in a sunflower field, sunflowers, (happy), photorealistic, (Highest picture quality), (Master’s work), (ultra-detailed), (Detailed eye description:1.2), masterpiece, best quality, absurdres, original, extremely delicate and beautiful, beautiful detailed eyes and face, (masterpiece:1.4),(best quality:1.4), 1girl, long hair, hair ornament, black hair, solo, breasts, flower, dress, hair flower, very long hair, bangs, full full body, beautiful face</em></p><p><strong>Negative prompt:</strong> <em>easynegative, badhandv4, nsfw,yallow,(((pubic))), ((((pubic_hair)))),sketch, duplicate, ugly, huge eyes, text, logo, monochrome, worst face, (bad and mutated hands:1.3), (worst quality:1.7), (low quality:1.7), (blurry:1.7),horror, geometry, bad_prompt, (bad hands), (missing fingers), multiple limbs, bad anatomy, (interlocked fingers:1.2),(interlocked leg:1.2), Ugly Fingers, (extra digit and hands and fingers and legs and arms:1.4), crown braid, (deformed fingers:1.2), (long fingers:1.2),succubus wings,horn,succubus horn,succubus hairstyle, multiple_hands, (bad-artist-anime), By bad artist -neg, deformed face , deformed hands</em></p><p><strong>Steps:</strong> 50, <strong>Sampler:</strong> DPM++ 2M Karras, <strong>CFG scale:</strong> 7, <strong>Face restoration:</strong> CodeFormer, <strong>Size:</strong> 512x512</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*puJWbtjBtaCbr2ZQhpte_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*h-Anpk3o3hZVsHLVhrPe7A.png" /><figcaption>Stable diffusion v1.5 (sinistra) — Stable diffusion 2.1 (destra)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*rfgahA3kLFGxYA8IX8sfAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*v42p6vBZjVlitUeN4dTNfQ.png" /><figcaption>AbyssOrangeMix2 (sinistra) — Anything V5 (destra)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*jwf7Ek2ItXLlasLDvYuzTA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*Gwr90xB4Q1Bk9IXFUwDvLg.png" /><figcaption>Break domain realistic (sinistra) — Dark sushi mix (destra)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*i9wFXZQiY_byme90QYxrBw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*pertW9fAZHO0QsZMuZUm_Q.png" /><figcaption>Dream shaper (sinistra) — DucHaitenDreamWorld (destra)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*lCWegjiZXw3wv04j8z4mYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*nal565BsdECNGwy8ySVQ6A.png" /><figcaption>Hassaku (sinistra) — Hellmix (destra)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*P_JPQ0lIJjRv6EchlLOFlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*sU7407l-u1rFEZ3yE3PN1w.png" /><figcaption>I Can’t Believe It’s Not Photography (sinistra) — Open journey (destra)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*1pUAExnKfkn7ZsoAlio4SA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*9Blyt5RPpufz-upG7e28lA.png" /><figcaption>Realistic vision v2 (sinistra) — Deliberate (destra)</figcaption></figure><p>Come si può notare, a parte i modelli di Stable Diffusion, sembra che gli altri tendano a mostrare donne con fattezze asiatiche. Tenete conto di questo quando create il vostro prompt.</p><h3>Dove trovare i modelli e come installarli?</h3><p>I file .ckpt possono contenere virus, quindi consiglio che scarichiate questi modelli da siti sicuri. Files .safetensor dovrebbero essere molto più sicuri.</p><p>Le due community dove trovare questi modelli sono:</p><ul><li><a href="https://huggingface.co/">Hugging face</a>: ricca community che riguarda tutto lo sviluppo dell’intelligenza artificiale. <br>Per scaricare un modello andate nella sezione “Files and versions” della pagina e quindi scaricate il file che finisce con .safetensor.</li><li><a href="https://civitai.com/">Civitai</a>: bellissima community focalizzata solo su Stable diffusion. Fate attenzione che, senza filtri, rischiate di imbattervi in parecchio porno.<br>Per scaricare un modello semplicemente cercate il vostro “Checkpoint” preferito e quindi cliccate su “Download”.</li></ul><p>Per utilizzare il modello in Stable diffusion webUI salvate il file in:</p><blockquote>stable-diffusion-webui/models/Stable-diffusion/</blockquote><p>ove stable-diffusion-webui è la cartella dove avete installato Stable diffusion webui.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iPPT9VkpvRT3twdx1AmDwQ.png" /></figure><p>Potete scegliere il modello cliccate sul menu a tendina o sul buttone segnati dalle frecce rosse. Se non vedete il modello fra quelli disponibili, aggiornate il menu cliccando sul buttone indicato dalla freccia verde.</p><p>E direi che per oggi sia tutto. <br>Se vi è piaciuta questa piccola guida condividete con amici e parenti e magari cliccate l’iconcina con gli applausi per farmi sentire soddisfatto.<br>Un saluto!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db4b4c9b4ce2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>