AiArt6 – Inpainting Revisited

by | Apr 16, 2024 | Art, Technology | 128 comments

I don’t like failing to solve a puzzle, so when I ended the Inpainting article on a defeat, I had to figure out a way to do it. So I did some research, and delved into features I don’t fully understand. I just knew that there were ways of making the engine use a sketch as a guide to image generation. So where did we leave off? We had an armored guy whose arm just refused to bend to the side and pretend to hold a banner pole. This guy-

Our starting image.

I had a large inpainting mask covering the whole banner and upper corner of the image. This created some fairly random results. So, how do we control the output better? It involves a feature I don’t fully understand called, appropriately enough, a Control Net. By default, the ComfyUI install doesn’t come with any control net modules. I went to the guys who made Stable Diffusion and found two – control_scribble and control_openpose, as each of these might do what I wanted to. I used the large mask image as a guide to where to draw in my crude sketch of a banner in hand. With these, I set up the new workflow. Here’s the section that’s been modified.

Am I contractually obligated to include these?

As the mask had been exported from the previous workflow into an image file, I decided to use an image to mask node to allow me to make easier adjustments to the mask in a friendlier editor (Photoshop). The one setting on the “Convert Image to Mask” node picks which color channel from the image to use as the mask. Since the image is either full black or full white, any channel other than Alpha works, so I left it on ‘Red’. This still feeds the VAE Encode for inpainting node and that latent goes into the sampler.

At the top, we have all the new stuff. The Load image should be familiar. Load Control Net Mode is just another basic loader, picking something from the ‘controlnet’ directory to feed the “Apply ControlNet” node. The advanced node has some more options and works on the positive and negative conditioning channels separately, the basic version works on a single conditioning channel, which might require a second node. I stuck with the advanced and put it between the prompts and the sampler. The only option I adjusted was the “strength”, which appears to work like any other weighting option to adjust the influence of the control net. At 1.00, I got a stone wall with my sketch drawn on it as a set of inscribed channels. So most of the time it ranged between 0.5 and 0.7 .

This did not get me what I wanted, as one of the results from the open pose control net got me an audience.

Now we have an audience.

I appreciate that the crowd is wearing a consistent uniform, and going to some lengths to stand on the architecture in some semblance of the pattern of my sketch. But this is not what I wanted. After some rethinking, I remembered the lesson from the outpainting article. The results are more reliable the smaller the area to be changed. As the image had a banner in it already, I drew a new mask which only included the current arm and the area I wanted the arm to move to. And ran through scads of iterations, adjusting settings, even adding more prompt elements. The system stubbornly didn’t want to have the arm held out to the side. It was insistent on keeping the arm down along the side. But finally, I stumbled onto a combination of weights that gave me this:

AI hands are notorious.

That’s a messed up arm, but it’s in the ballpark. So I shrank the mask again to just the region of the new arm and ran the inpainting again. The engine promptly decided to try to move the arm back to the side, even amputating the hand because it stuck outside the mask region. This frustrated me for some time, but I again went back to the lessons learned. It can’t move the arm if we don’t give it the space to change those parts which are good. I started drawing tiny masks, nudging the arm into shape, even drawing one from a prompt of “desert, rocks,” to simply erase some of the excess arm. I ran into the same hesitance to leave the arm on the side when I tried to redraw the hand. The first attempts resulted in the hand vanishing, so that it could move back to the side, outside the inpainting mask. I had to use a prompt of “hand, glove, fist, holding pole” to keep the hand in place, though the first iteration was a bit off, giving him three fingers and a fat thumb. At little more tweaking, and he had all his fingers back, but still a fat thumb.

Finally! …wait

Sure this means the flag is slightly small, but he has a hand within margins of error. But I’ve noticed a problem. For whatever reason, all the inpaint runs darkened the main image and made it blurry. I’m not sure why there’s anything being done to those pixels. But I want to clean it up. I could merge the two in photoshop, but I already have everything I need in ComfyUI, so I’m going to do something that may sound odd, but is perfectly valid. I’m going to disconnect the latent feed from the sampler. Without the latent, the sampler won’t run. I’m going to pull in another image loader, and then feed a new node.

No resampling

In the middle there is an “ImageCompositeMasked” node. I couldn’t find any good documentation on this, but made some educated guesses. Since both the source and destination are the same size, I didn’t need to turn on resizing for the source. The mask I used was the second inpainting mask I created that covered the original and intended arm position. So the only question was which image was supposed to be the source and which was the destination. Based upon the behavior of other nodes, the source is what gets placed inside the masked area, and the destination is the background it gets placed over. So the original, brighter image is the destination, and the faded, inpainted image is the source. I didn’t bother to feed the image output to any of the more sophisticated nodes, just a preview node from which I could save the result if I liked it.

After all that work, here is the result:

Finally?

I’m going to claim success.

It’s about time.

We’ve now finished a review of the basic user experience…

… the basic…

… basic …

… …

Dammit.

About The Author

UnCivilServant

UnCivilServant

A premature curmudgeon and IT drone at a government agency with a well known dislike of many things popular among the Commentariat. Also fails at shilling Books

128 Comments

  1. Sean

    Seems very frustrating.

    Have you tried herding cats? Might be easier.

    Those floating scraps in the upper left annoy me.

    • Brochettaward

      Seconders are from Venus, Firsters are from Mars.

      • Sean

        What planet has the armor clad twinks?

      • EvilSheldon

        Maybe it’s the armor, but that dude has hourglass curves like Betty Boop. That’s not a criticism. He would definitely be my cellmate in the labor camps…

      • slumbrew

        I don’t know, man, I think you’ll have to get in line.

      • rhywun

        He is very pretty.

      • Brochettaward

        I hear that if you go gay in the camps, they’ll have to release you.

  2. Sensei

    Any clue how it chose the halo around the head?

    • UnCivilServant

      No.

      I’ve not isolated what caused that.

      • R.J.

        Divine Intervention.

  3. The Late P Brooks

    I can’t help thinking there is some sort of Escher-like perspective violation going on there. It’s not quite as pronounced in the final image, but it still haunts me.

    In other news, I managed to get my trash picked up. I dragged the can out to the road a little while ago, and I had barely made it back inside when heard the truck coming up the road. Last week, I didn’t get it out in time. They are rather unpredictable. Sometimes they’re early, sometimes they’re late, and sometimes they don’t show up at all.

    • trshmnstr

      That’s why I always do it the night before. Their station is a block over from us, so they’re at our place really early.

      I need to call them to get some of the building materials from the previous owners hauled off. There is plenty ill keep, too. They left probably $1k in lumber, 40 cinder blocks, 10 bags of soil, and various odds and ends.

      • Fourscore

        That’s a pretty good haul of free stuff. Can always trade it with the neighbors for some good will when you need an extra hand.

  4. The Late P Brooks

    Those floating scraps in the upper left annoy me.

    Pretend they are communists falling from helicopters.

    • Not Adahn

      Seagulls.

  5. Not Adahn

    To me that doesn’t look like a small flag, it looks like the prince is playing a forced-perspcctive game.

    • UnCivilServant

      It is a forced perspective game. I got to something that was close enough and went “Fine! Done! Happy now?!”

      • R.J.

        I am. Thanks for all the hard work figuring this out. It still blows my mind that hands are so difficult for AI.

  6. The Late P Brooks

    Opening volley of the PR blitz?

    For the next three months NPR will dig into the matters you’ve signaled are most important to you when choosing a leader with outsized power to shape the issues and the results. Consistently top of mind for NPR listeners and readers are the often complicated questions related to gun violence, the economy, immigration, reproductive rights, healthcare, and U.S. foreign policy.

    NPR’s specialty is our ability to deliver local, national and international perspectives in partnership with Member stations in cities and towns, large and small and across the political spectrum. We work hard to fairly present differing viewpoints that provide a complete picture. Our hope? That our rigorous and respectful reporting spurs meaningful conversations within our broadcast programs, on our site and podcasts and at dinner tables across the land that help you decide what’s right for you, your family and your community.

    “We have both kinds of music; country, and western.”

    We’re totally honest and unbiased. Just take a gander at our rainbow coalition. Some of them even identify as capitalists, or men.

    • The Other Kevin

      This is really an unfortunate week for them to put that article out.

      • R.J.

        Those geniuses just suspended the guy who questioned their left-wing bias.

      • The Other Kevin

        Signaling loud and clear, that bias is not a problem. Fast forward a few months, and they’ll wonder why they’re losing listeners.

      • R.J.

        Oh, they don’t care. Government entity and all.

      • rhywun

        Saw that. Hilarious.

    • Not Adahn

      PROJECT SCHEDULE
      • Gun Violence — this week
      • Economy — week of April 22
      • Immigration — week of May 6
      • Abortion and Reproductive Rights — week of May 20
      • Health Care — week of June 3
      • Foreign Policy — week of June 20

      It must have killed them not to dedicate a month to “White Supremacy and Threats to Democracy.”

  7. UnCivilServant

    Next week, we leave this overlong series on AI art to do an Even Longer series on me trying to build a clock from base components.

    • EvilSheldon

      Nixie tubes?

      • UnCivilServant

        Not yet.

        That’s on my Eventual Goals list. But right now it’s with a seven segment LED display (significantly cheaper to make mistakes with)

      • EvilSheldon

        That is the honest truth. I’ll be following this one.

      • UnCivilServant

        You know, I’ve run into a lot of 600 page reference books since I started looking into circuits.

      • UnCivilServant

        This looks like a big binder of data sheets. If all that’s in here is datasheet information for several hundred TTL chips, I’m somewhat disappointed.

      • UnCivilServant

        🤣

        I recognised the data sheet for a shift register just from the timing digram. I stared at that darn thing so much it’s burned into my brain.

  8. kinnath

    OT

    MPs to vote on smoking ban for those born after 2009

    The Tobacco and Vapes Bill would ensure anyone turning 15 from this year would be banned from buying cigarettes, and also aims to make vapes less appealing to children

    These children will be tattooed to make it obvious that the are not allowed to smoke.

    • Sean

      Utopia is just around the corner.

    • Stinky Wizzleteats

      Kids, the good news is you’ll live longer. The bad news is you’ll have to do that in the authoritarian shithole that is modern Great Britain.

    • Fourscore

      Next they’ll want to outlaw drugs. And guns. And meat. And discriminatory weather.

    • EvilSheldon

      Don’t feel too bad. Uri will head on out to make those sweet Substack bucks, and it’s not like NPR (or NPR listeners) are capable of self-reflection…

      • The Other Kevin

        He’ll end up there or at The Free Press. The list is getting long of people who’ve been canceled but are putting out better work and making more money.

      • Stinky Wizzleteats

        It just gets a bit frustrating seeing the good guys getting fucked by the bad guys over and over again but you’re right, he’ll land on his feet.

      • Not Adahn

        “Good guy” being a relevant term. He apparently believes NPR was truthful and unbiased before OMB ruined everything.

      • Not Adahn

        Relative term, not relevant. Or revenant. Or even repugnant.

      • EvilSheldon

        Definitely not a good guy. A good guy would have made this same stand in 2020.

      • Compelled Speechless

        I don’t remember who it was, but it was pointed out the wokeness is a religion, but perhaps it’s most important missing feature is it’s opportunity for redemption. If you want our side to win, it’s important to keep that in mind.

      • JaimeRoberto (carnitas/spicy salsa)

        Maybe he tried to make his point internally in 2020 or at least before this. Maybe because he was in the bubble he didn’t see what was coming. I’m willing to give him some benefit of the doubt.

      • Fatty Bolger

        It’s never too late to renounce communism, er, wokeism.

      • kinnath

        NPR was never unbiased. It was always openly liberal.

        Now it is woke. Woke is as anti-liberal as it is anti-conservative.

      • Fatty Bolger

        He admits they were always liberal leaning, the complaint is how they veered from that into straight up political activism.

      • R.J.

        PBS needs a PBS Classic channel, which hosts original Cosmos, Monty Python, Benny Hill, and STFU about news. It would be a runaway success.

      • Drake

        Yes! I loved Benny Hill.

      • Fourscore

        Hope I’m not on Uri’s list, that would not be comfortable.

        “Hey, Uri, it’s you and me, right? All the way, right? Right?
        C’mon man, I was just kidding”

      • rhywun

        They’re led by a commie shitbag? I am shocked.

      • Stinky Wizzleteats

        Strap in boys, we’re approaching the wokularity.

      • Compelled Speechless

        The far left’s infatuation with Islamic fundamentalism is purely based on kneejerk contrarianism to the neo-conservative’s “Islamic terror is everywhere!!!!” schtick. How do you get so far up your own ass that you are willing to die on the hill of protecting people that would horrifically torcher and murder you within 5 minutes of you explaining your world view to them? I thought the right was supposed to be the irrational reactionaries.

      • Compelled Speechless

        **torture** 🤦‍♂️

      • rhywun

        Holy crap she’s delusional.

      • Sean

        There’s a lot of that going around these days.

      • JaimeRoberto (carnitas/spicy salsa)

        Oh she’s real, and she’s spectacular. Spectacularly woke.

      • kinnath

        Christian theocracy is bad.

        Islamic theocracy is good.

        Thus speaketh the woke.

    • Urthona

      He’s not “done”. He is suspended for 5 days. I don’t agree with it but meh.

      • Not Adahn

        His coworkers are already saying he makes them feel “unsafe.” That’s the magic word. He’s done.

      • Not Adahn

        Plus, he received in writing that this incident was his “last warning” before termination. And the incident was creating content for non-NPR news sources.

      • Urthona

        Yeah. One of the easy ways you can tell that the Republican party in this country is simply fake is that a very obvious propaganda tool for the government still keeps its funding in perpetuity.

        The arguments they make against cutting it are “it’s such small amount of money”.

        Dude, it’s literally government funded propaganda It’s the principle.

        I should not have to care about this shitty organization at all.

      • Drake

        How many guys have been ‘suspended’ for wrongthink while the bosses and lawyers worked up the courage to fire them?

        If they go according to plan, they’ll make him grovel and apologize for a few days, then fire him anyway.

      • Compelled Speechless

        Exactly. The “cause” will present itself very shortly.

        Beria is grinning in his grave.

  9. The Late P Brooks

    Those geniuses just suspended the guy who questioned their left-wing bias.

    “Here at NPR, we recruit and hire the best young journalists in the country from a pool as deep and wide as the nation itself. They are a diverse bunch, but they are all incredibly bright and perceptive. They see the world for what it is, not what a bunch of delusional racist homophobic fanatics wish it to be. They have analyzed the world around them, and have reached conclusions which may give the appearance of uniformity, but only because they are uniformly correct. That’s inescapable.”

  10. Not Adahn

    Anybody worked with these guys? They are suspiciously local.

    https://www.kitware.com/

    • Drake

      Misread and assumed they made kilts before clicking.

    • UnCivilServant

      Never heard of them, but that site waves enough red flags for a mayday prarade through red square.

      • Not Adahn

        Which are these? Such things are not in my realm of expertise.

      • Sean

        I’ll start with that photo on the front page.

      • Not Adahn

        The corvette or the fat chick with the surgical tools?

      • Not Adahn

        Or the employee pic that is shamefully non-diverse?

      • Sean

        They care so much for their employees, they cut their faces off.

        lol

      • Not Adahn

        I can see how lack of concern for the excessively tall would bother you.

      • Sean

        the fat chick with the surgical tools?

        Her and the guy in the background with the goofy face. That’s the best they can do?

      • Not Adahn

        I would assume that a competent software company wouldn’t have attractive women coders. Plus she’s an Upstate 6, alas.

      • UnCivilServant

        I start from 100% employee owned, plus they brag about working with government in NY.

  11. The Late P Brooks

    His coworkers are already saying he makes them feel “unsafe.” That’s the magic word. He’s done.

    Hey, this ditch is full of dead people. Why did you bring me here?

    • Urthona

      Pretty “unsafe” of him to suggest NPR has no conservative voices.

    • EvilSheldon

      “Feeling unsafe, huh? So, where’s your gun?”

    • Compelled Speechless

      I’ve been listening to the “Revolutions” podcast. Thanks again to whoever recommended it. I’m on the French Revolution.

      Fun fact: The original name for the group headed by Robespierre at the beginning of the terror was “The Committee for Public Safety.”

    • EvilSheldon

      Worse than the field-expedient flotation is the dude running the gun with no stock, that close to his face. He’s going to eat the receiver cover if he fires that thing.

      Even worse than that is that we are paying for the military assets deployed to train these dingleberries…

      • Sean

        I’m not sure what he’s aiming at, as his sights are blocked. *shrug*

        I think it’s an under folder, with the stock bound in place by the duct tape.

    • UnCivilServant

      Is supect the headline could more accurately read: “NASA confirmed with legal department that they have some sort of protection from liability for falling space debris.”

      • Compelled Speechless

        What’s the old saying? “We’re from the government and we’re here to……waive off our liability and never take responsibility for any negative outcomes of our operations.”

      • kinnath

        The atmosphere failed to eat our garbage.

        Act of god.

        Not my problem.

      • Sean

        Act of god.

        Home owner’s insurance: “Denied!”

      • Fourscore

        Is there a check mark on Homeowner’s Insurance as to whether one is a believer?

        I’m not a believer so no act of god if a tree falls on my house or the snow shears off the chimney (as it has in the past 2 years). Must be a caveat for those sorts of accidents.

    • The Other Kevin

      A frozen block of space poop?

      • Nephilium

        So even if you don’t live near a strategic base, your house isn’t necessarily safe from an icy BM.

      • Not Adahn

        *applause*

      • Nephilium

        I can’t take full credit for that. Spider Robinson had an ongoing pun competition through the series of Callahan’s Crosstime Saloon, and one of the stories was about the plane building up blue ice and dropping it. Still doesn’t come up with the king of the flower people who fell in love with a prostitute. In the end he learned that he could lead a whore to culture, but couldn’t make her think.

  12. juris imprudent

    Massie joins MTG in questioning Johnson’s fitness to be Speaker. I agree if the asshole is going to defend himself thus:

    “We need steady hands at the wheel. I regard myself as a wartime speaker,” he said, pointing to the challenges facing the country and his narrow majority. “I didn’t anticipate that this would be an easy path.”

    WSJ (and presumably pay-locked) via RCP

    • juris imprudent

      Baldwin can only hope she is his sacrificial goat, she could also be a harbinger of doom for him.

      • R.J.

        If you read that whole article, at one point her text messages were subpoenaed and she was calling the jury idiots and assholes. This is a learning and growing moment: Don’t insult people at trial in any traceable fashion.

        https://www.youtube.com/watch?v=Z45-FQsTzWo

  13. juris imprudent

    And in other good news.

    The court’s conservatives questioned whether the 2002 Sarbanes-Oxley Act, which was aimed at corporate accounting fraud, can be used more broadly to prosecute those who obstruct “any official proceeding,” including Congress’ 2021 certification of President Biden’s election victory.

    Chief Justice John G. Roberts Jr. and Justice Neil M. Gorsuch noted that the law made it a crime to destroy or conceal documents to impair an “official proceeding,” but they voiced doubt over extending that to any disruptions of a proceeding.

    If someone “pulls a fire alarm” to delay a vote in Congress, is that a federal felony subject to 20 years in prison, Gorsuch asked.

    • Nephilium

      If someone “pulls a fire alarm” to delay a vote in Congress, is that a federal felony subject to 20 years in prison, Gorsuch asked.

      Nice…

      • Not Adahn

        What was counsel’s reply to that?

    • R.J.

      I wonder whomever Gorsuch may be talking about?

      • Fatty Bolger

        Nobody, of course, it was just hypothetical. 😉

  14. Not Adahn

    Is that character’s name Prince Bishonen, and if not why not?

    • R.J.

      Heh!
      Purty mouth and all that.

      • UnCivilServant

        It’s strange what glibs latch onto. I picked a randomimage to use in demonstrating inpainting, and you guys have become fixaed on his looks.

        … he’s not real, you know.

      • Not Adahn

        I commented last time about how WTF that armor is in response to a “desert punk” prompt.

      • UnCivilServant

        That is the effect of the Black And Gold Marble LoRA – it’s got a very strong influence relative to the DesertPunk LoRA. Without the effect of the black and gold marbled attire LoRA, desertpunk produces images like Kingdom of Dust here.

      • Not Adahn

        Also, in one of my first rye reviews, all the comments were about how I needed to clean my stove.

      • UnCivilServant

        Well, did you clean your stove?

    • UnCivilServant

      Because I don’t name images the AI pops out.

    • Sean

      Ewwww…CNN.

      • Sean

        I have an employee who I call “CNN” when he says something completely wrong.

      • R.J.

        Fantastic. I am stealing that idea.

      • juris imprudent

        An update to the old Cheers’ bit about pulling your head out of your Clavin?

    • The Other Kevin

      That sounds like an endorsement to me. Apparently it would be better if most Americans were hurt by a tax law, but the wealthy were hurt most.

      • UnCivilServant

        “It’s better that the poor be poorer so long as the other rich are less rich… but leave me alone.”

  15. The Late P Brooks

    If you read that whole article, at one point her text messages were subpoenaed and she was calling the jury idiots and assholes. This is a learning and growing moment: Don’t insult people at trial in any traceable fashion.

    And don’t bother to pretend the phones in the freaking JAIL aren’t tapped.

  16. The Late P Brooks

    Progressive tax rates – how do they work?

    People who actually pay taxes are disproportionately affected by tax policy? No way.